-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added ability to validate the number of decimal places #427
Conversation
Signed-off-by: Richard Tomlinson <richard.tomlinson@matchesfashion.com>
Signed-off-by: Richard Tomlinson <richard.tomlinson@matchesfashion.com>
Signed-off-by: Richard Tomlinson <richard.tomlinson@matchesfashion.com>
Signed-off-by: Richard Tomlinson <richard.tomlinson@matchesfashion.com>
Added ability to validate the number of decimal places
|
||
return this._test('precision', limit, function (value, state, options){ | ||
|
||
var decimalPlaces = value.toString().match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving the regex out gives about 2-4% performance boost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how did you measure that? running the tests against the two versions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
running the isolated code using bench.
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions. |
We needed this to help validate currency fields to ensure that the correct level of precision was presented.