Validators for Modella
A plugin that provides a bunch of validators for modella.
var Person = modella'Person'attr'name' required: truevalidation = require'modella-validators';Personusevalidation;
Verifies that a field is present.
var User = Userattr'username' required: true;
Verifies that a field equals another field.
var User = Userattr'password'attr'passwordConfirmation' confirms: 'password' ;
Checks that a field is of a given type
var User = Userattr'name' type: 'string';
In addition to string support for primitives, you can also pass in a constructor.
var User = Userattr'parent' type: User ;
Checks that a field is one of the specified choices
var User = Userattr'state' choices: 'CONFIRMED' 'PENDING'
Verify the value of a field against a regex pattern.
comes with a few regex strings built in under the
Validates the field against the given regular expression
var User = Userattr'name' format: /\w+ \w+/ ;
Validates the field against a (North American) phone number format
var User = Userattr'phone' format: 'phone' ;
Validates the field against a email address format
var User = Userattr'email' format: 'email' ;
Validates the field against a URL format
var User = Userattr'website' format: 'url' ;