English 中文(简体)
np 有效器在阳性鉴定中不实回报,但仍提出质询。
原标题:npm validator returns false in mongoose validation but still submits query

我正在进行县级鉴定。 我正试图把名称放在我的羊.中,以证实字母和空间,但没有数字。 有效器在使用Npm有效器时。 阿尔法功能()正在退回假的,但依然在我的数据库中制作文件。 我不敢肯定会发生什么情况,因为我认为,证明是失败的,因此不应建立该文件。 是否有任何想法或建议?

  {
    name: {
      type: String,
      required: [true,  A tour must have a name ],
      unique: true,
      trim: true,
      maxlength: [40,  A tour name must have less or equal than 40 characters ],
      minlength: [10,  A tour name must have more or equal then 10 characters ],
      // validate: [validator.isAlpha,   Tour name must only contain characters ]
      validate: {
        validator: function (val) {

          console.log(val);
          console.log(validator.isAlpha(this.name,  en-US , { ignore:     }));


          validator.isAlpha(this.name,  en-US , { ignore:     });

        },
        message:  At tour must only contain letters 
      }
    }
  }

Console.log(val) 印刷了插头(即“john doe 35”)和锥体。

问题回答

You are not return the validated result in validator function.
See custom-validators
return validator.isAlpha(this.name, en-US , { ignore: });





相关问题
Bind Button.IsEnabled to custom validation with XAML?

I am sorry I didn t know how to title my question any better, you name it if you got a good 1. I have an entity Contact. this person has navigation properties: Address, Phones (A collection of Phone)....

WPF - MVVM - NHibernate Validation

Im facing a bit of an issue when trying to validate a decimal property on domain object which is bound to a textbox on the view through the viewmodel. I am using NHibernate to decorate my property on ...

Wpf Combobox Limit to List

We are using Wpf Combobox to allow the user to do the following things: 1) select items by typing in the first few characters 2) auto complete the entry by filtering the list 3) suggesting the first ...

Rails 101 | validates_currency?

I ve searched high and low, but I could not find a solution, to what I think seems like a very common task. In a form I want to have a text input that accepts currency strings (i.e. $1,000,000 or ...

CodeIgniter form verification and class

I m using the form validation library and have something like this in the view <p> <label for="NAME">Name <span class="required">*</span></label> <?...

热门标签