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

Commit 01f73b1

Browse files
author
Alfredo Delgado
committed
Add numericality example with multiple custom messages.
1 parent 1fa5408 commit 01f73b1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

index.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,6 +1703,23 @@ <h2>Validators</h2>
17031703
validate({duration: "7"}, {duration: {numericality: {divisibleBy: 3}}});
17041704
// =&gt; {"duration": ["Duration must be divisible by 3"]}
17051705

1706+
var constraints = {
1707+
weight: {
1708+
numericality: {
1709+
greaterThan: 0,
1710+
notGreaterThan: 'must be greater than 0.',
1711+
lessThan: 999,
1712+
notLessThan: 'must be less than 9999.'
1713+
}
1714+
}
1715+
};
1716+
1717+
validate({ weight: 0 }, constraints);
1718+
// =&gt; { weight: [ 'Weight must be greater than 0.' ] }
1719+
1720+
validate({ weight: 1000 }, constraints);
1721+
// =&gt; { weight: [ 'Weight must be less than 9999.' ] }
1722+
17061723
var constraints = {
17071724
duration: {
17081725
numericality: {

0 commit comments

Comments
 (0)