Custom validations are also possible
Optional
containsforce specific substrings
Optional
equalsonly allow a specific value
Optional
is{ is: ['^[a-z]+$','i'] }
will only allow letters{ is: /^[a-z]+$/i }
also only allows lettersOptional
isonly allow date strings after a specific date
Optional
iswill only allow letters
Optional
iswill only allow alphanumeric characters, so "_abc" will fail
Optional
isonly allow arrays
Optional
isonly allow date strings before a specific date
Optional
ischeck for valid credit card numbers
Optional
isonly allow date strings
Optional
ischecks for any numbers
Optional
ischecks for email format (foo@bar.com)
Optional
ischecks for valid floating point numbers
Optional
isIPchecks for IPv4 (129.89.23.1) or IPv6 format
Optional
isIPv4checks for IPv4 (129.89.23.1)
Optional
isIPv6checks for IPv6 format
Optional
ischeck the value is one of these
Optional
ischecks for valid integers
Optional
ischecks for lowercase
Optional
isonly allows null
Optional
iswill only allow numbers
Optional
isUUIDonly allow uuids
Optional
ischecks for uppercase
Optional
ischecks for url format (http://foo.com)
Optional
lenonly allow values with length between 2 and 10
Optional
maxonly allow values
Optional
minonly allow values >= 23
Optional
not{ not: ['[a-z]','i'] }
will not allow lettersOptional
notdon't allow specific substrings
Optional
notdon't allow empty strings
Optional
notcheck the value is not one of these
Optional
notwon't allow null
Model validations, allow you to specify format/content/inheritance validations for each attribute of the model.
Validations are automatically run on create, update and save. You can also call validate() to manually validate an instance.
The validations are implemented by validator.js.