Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Commit

Permalink
Add numericality example with multiple custom messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfredo Delgado committed Apr 9, 2018
1 parent 1fa5408 commit 01f73b1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1703,6 +1703,23 @@ <h2>Validators</h2>
validate({duration: "7"}, {duration: {numericality: {divisibleBy: 3}}});
// =&gt; {"duration": ["Duration must be divisible by 3"]}

var constraints = {
weight: {
numericality: {
greaterThan: 0,
notGreaterThan: 'must be greater than 0.',
lessThan: 999,
notLessThan: 'must be less than 9999.'
}
}
};

validate({ weight: 0 }, constraints);
// =&gt; { weight: [ 'Weight must be greater than 0.' ] }

validate({ weight: 1000 }, constraints);
// =&gt; { weight: [ 'Weight must be less than 9999.' ] }

var constraints = {
duration: {
numericality: {
Expand Down

0 comments on commit 01f73b1

Please sign in to comment.