The Validate plugin adds a method to the API wrapper which provides validation of multiple data types.
validate() method accepts 4 arguments, of which only the first is required:
[string](validation type to use)
[mixed](mode of the validation type used)
nano('input').validate('string', null, 5, 12);
This would check that the text in "input" is a
string, and that it is between 5 and 12 characters in length.
By default, the
validate() method checks that the value is not
false. The available validation types are:
- date (mode is a date mask that checks the format of the input)
- time (mode is a date mask that checks the format of the input)
- password (if mode is boolean "true" then the password must also contain symbols)
- string (if mode is a string the input must be the same)
- object (mode is the name of a property that must exist in the object)