leading/trailing spaces trip up validation
At least it does for numericality.
The numericality validator uses parseInt to extract the integer and the following works with trailing whitespace:
parseInt(" 1234 ")
> 1234
So a few questions to help diagnose your issue:
- What browser/version are you using?
- What does the model validation look like?
- chrome 16.0.912.75 m on Win7
- validates :answer, :presence => true, :numericality => { :only_integer => true }
On Fri, Feb 3, 2012 at 5:35 PM, Brian Cardarella < [email protected]
wrote:
The numericality validator uses
parseIntto extract the integer and the following works with trailing whitespace:parseInt(" 1234 ") > 1234So a few questions to help diagnose your issue:
- What browser/version are you using?
- What does the model validation look like?
Reply to this email directly or view it on GitHub:
https://github.com/bcardarella/client_side_validations/issues/268#issuecomment-3807402
Ah, yup that's a bug. For :only_integer we are doing a regular expression match. Thank-you. I'll fix in master.