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

Commit 6d99563

Browse files
committed
Document the strict option for the numericality validator
1 parent 578426d commit 6d99563

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,6 +1560,8 @@ <h2>Validators</h2>
15601560
<dl class="dl-horizontal">
15611561
<dt>onlyInteger</dt>
15621562
<dd>Real numbers won't be allowed. The error message is <i>must be an integer</i></dd>
1563+
<dt>strict</dt>
1564+
<dd>Enables more strict validation of strings. Leading zeroes won't be allowed and the number cannot be malformed.</dd>
15631565
<dt>greaterThan</dt>
15641566
<dd>The input has to be greater than this value. The error message is <i>must be greater than %{count}</i></dd>
15651567
<dt>greaterThanOrEqualTo</dt>
@@ -1601,6 +1603,12 @@ <h2>Validators</h2>
16011603
validate({duration: "3"}, {duration: {numericality: true}});
16021604
// =&gt; undefined
16031605

1606+
validate({duration: "03"}, {duration: {numericality: true}});
1607+
// =&gt; undefined
1608+
1609+
validate({duration: "03"}, {duration: {numericality: {strict: true}}});
1610+
// =&gt; {"duration": ["Duration must be a valid number"]}
1611+
16041612
validate({duration: "3"}, {duration: {numericality: {noStrings: true}}});
16051613
// =&gt; {"duration": ["Duration is not a number"]}
16061614

@@ -2274,6 +2282,11 @@ <h3>
22742282
utility method. Thanks <a href="https://github.com/ansman/validate.js/pull/111" target="_blank">jpbufe3</a>
22752283
for suggesting an implementing this.
22762284
</li>
2285+
<li>
2286+
Added a strict option to the<a href="#validators-numericality"><code>numericality</code></a>
2287+
validator. Thanks <a href="https://github.com/ansman/validate.js/pull/106" target="_blank">mondwan</a>
2288+
for suggesting and implementing this.
2289+
</li>
22772290
</ul>
22782291
</div>
22792292
<div id="changelog-0-9-0">

0 commit comments

Comments
 (0)