Drew Colthorp

Float auto-validation doesn't work as expected

Reported by Drew Colthorp | September 27th, 2008 @ 03:21 PM

I set up my fixtures to populate some Float fields with numbers based on Kernel#rand. To my surprise, I found that my fixtures were invalid and that the floating point numbers which were assigned to my Float properties were not, despite all outward appearances, numbers.

The Float auto-validation uses validates_is_number and specifies property.precision and property.scale as the :precision and :scale options respectively. The end result is that setting 0.0123456789 to a Float property makes the model invalid, while setting 0.012345678 to the property does not.

I would expect to be able to assign any Float to a property of type Float and have it succeed unless I've explicitly added validations for precision and/or scale.

Comments and changes to this ticket

  • Gary Yngve

    Gary Yngve December 8th, 2008 @ 12:47 AM

    • Tag changed from dm-more, property, validations to dm-more, property, validations
    • State cleared.
    • Assigned user cleared.

    Any news on this? I'm getting this bug too.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Pages