diff --git a/index.html b/index.html index cceb43d..0241ca8 100644 --- a/index.html +++ b/index.html @@ -1703,6 +1703,30 @@

Validators

validate({duration: "7"}, {duration: {numericality: {divisibleBy: 3}}}); // => {"duration": ["Duration must be divisible by 3"]} +var constraints = { + weight: { + numericality: { + notValid: 'is required', + greaterThan: 0, + notGreaterThan: 'must be greater than 0', + lessThan: 9999, + notLessThan: 'must be less than 9999' + } + } +}; + +validate({ weight: null }, constraints); +// => undefined + +validate({ weight: '' }, constraints); +// => { weight: [ 'Weight is required' ] } + +validate({ weight: 0 }, constraints); +// => { weight: [ 'Weight must be greater than 0.' ] } + +validate({ weight: 10000 }, constraints); +// => { weight: [ 'Weight must be less than 9999.' ] } + var constraints = { duration: { numericality: {