Skip to content
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

should_validate_numericality_of less_than/greater_than works incorrectly with floating point numbers #13

Open
mcm8 opened this issue Feb 26, 2010 · 0 comments

Comments

@mcm8
Copy link

mcm8 commented Feb 26, 2010

my_model_spec.rb:
should_validate_numericality_of :testfield, :less_than => 10.1

my_model.rb
validates_length_of :testfield, :less_than => 10.1

Gives the following error:
'MyModel should ensure numericality of testfield is less than 10.1' FAILED
Expected MyModel to be invalid when testfield is greater than 9.1

The equivalent error happens on :greater_than (but NOT on the _or_equal versions).
(A workaround for floating point numbers ending in .0 is to only specify the integer part on the validator in the model class - in this case no error appears.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant