leading/trailing spaces trip up validation #268

Closed
kellerapps opened this Issue Feb 4, 2012 · 3 comments

Projects

None yet

2 participants

@kellerapps

At least it does for numericality.

@bcardarella
Contributor

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:

  1. What browser/version are you using?
  2. What does the model validation look like?
@kellerapps
  1. chrome 16.0.912.75 m on Win7
  2. validates :answer, :presence => true, :numericality => { :only_integer
    => true }

On Fri, Feb 3, 2012 at 5:35 PM, Brian Cardarella <
reply@reply.github.com

wrote:

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:

  1. What browser/version are you using?
  2. What does the model validation look like?

Reply to this email directly or view it on GitHub:

#268 (comment)

@bcardarella
Contributor

Ah, yup that's a bug. For :only_integer we are doing a regular expression match. Thank-you. I'll fix in master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment