10.4.7 Validators
10.4.7.1 dateRange
Specifications
dateRange
- minDate (Date) : the minimum required date
- maxDate (Date) : the maximum required date
- validate (object) : checks if the provided object is a date and is positioned between the minimum and the maximum date (minimum and maximum not included)
10.4.7.2 dateRangeOrder
Specifications
dateRangeOrder
- order: "asc"
- strict: false
- -
- validate (object) : checks if the provided object's date members start and end are in the correct order (ascending, strictly ascending, descending or strictly descending)
10.4.7.3 dayOfWeek
Specifications
dayOfWeek
- dayOfWeek : which day of the week needs to be checked ( 0 = sunday , 6 = saturday)
- _days : array containing week day names (starting with sunday, ending with saterday)
- validate (object) : checks if the provided object is a date and is weekday
Example
{
"base" : "dayOfWeek"),
"dayOfWeek" : 0
}
new Date(2008, 7, 31)
validates (is a sunday)
new Date(2006, 7, 30)
Does not validate (isn't a sunday)
10.4.7.4 fieldComparer
Specifications
fieldComparer
- fieldA : first field needed for validation
- fieldB : second field needed for validation
- operation : operation used for validation, possible operation are:
- eq : compare for equality valA and valB
- lt : valA < valB
- gt : valA > valB
- lte : valA <= valB
- gte : valA >= valB
- validate (object) : compares the 2 fields using the operation specified
Used in
10.4.7.5 isDate
Specifications
isDate
- patterns (string array) : a list of patterns that can express the date format. By default this is yy-mm-dd and dd/mm/yy.
- validate (object) : checks if the provided object is a date or can be changed into a date.
Used in
10.4.7.6 isEmail
Specifications
isEmail
- validate (String) : checks if the provided String is a valid e-mail address (email regex from - http://www.regular-expressions.info/email.html)
10.4.7.7 isInt
Specifications
isInt
- validate (object) : checks if the provided object is valid number or can be converted into one
Used in
10.4.7.8 isIntRange
Specifications
isIntRange
isInt
- validate (object) : checks if the provided object is a int range { start : Number, end: Number}
Used in
10.4.7.9 isOption
Specifications
isOption
- validate (value, data) : checks if the provided value is available in the options list given as second argument
10.4.7.10 isUrl
Specifications
isUrl
- validate (String) : checks if the provided String is a valid uri (uri regex from http://www.osix.net/modules/article/?id=586)
10.4.7.11 length
Specifications
length
- min : the minimum length (default to 0)
- max : (optional) the maximum length
- validate (object) : checks if the provided object (String or Array) is of provided length
10.4.7.12 range
Specifications
range
- min : required minimum (optional)
- max : required maximum (optional)
- step : required step (optional)
- validate (object) : checks if the provided object is between the minimum and maximum and -if between- a required step
Only integer steps are implemented so far
Used in
Example
{
"base" : "range",
"min" :-10,
"max" :10,
"step" :3
};
-15 : does not validate
-14 : does not validate
-12 : does not validate
-11 : does not validate
-10 : does validate
-9 : does not validate
-8 : does not validate
-7 : does validate
7 : does validate
"some text" : does not validate
10.4.7.13 regex
Specifications
regex
- regex (String) : the regex used to validate
- validate (object) : checks if the provided object validates the regex
Example
Pattern for a Belgian national register number: xx.xx.xx-xxx.xx
"+validators" : {
regex:{
"regex":/\d{2}\.\d{2}\.\d{2}-\d{3}\.\d{2}/
}
}
10.4.7.14 remote
Specifications
remote
- location: location path for remote validation
- validate (value, validationData) : validate wireData in remote validation
10.4.7.15 required
Specifications
required
- validate (value) : check of the provided value is not empty
Previous