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

Description
Goal:
- Expect
"010" to be false in numericality validator
Description:
It will be great if there is an option like noLeadingZero in numericality.
Why
- Value from HTML5 number box is string
- The coercion of
+ will force "010" to be 10
Facts above make 010 to be a valid number which it should not be in reality in my opinion.
JS:
var c = {
"numericality": {
"greaterThanOrEqualTo":1,
"lessThanOrEqualTo":100,
"message":"<id> from 1 to 100",
},
"presence": true,
};
// Expect to be false, but get true
console.log(
'validation result ',
validate.single('010', c)
);
// No problem
console.log(
'validation result ',
validate.single('10', c)
);
Fiddler:
https://jsfiddle.net/8okbtbuz/2/