#996 ✓resolved
Shane Hanna

dm-validations stringy regexp validations fail scientific notation

Reported by Shane Hanna | July 31st, 2009 @ 12:37 AM | in 0.10.0

I have a couple Float values in my database. The validations in dm-validations kept giving me validations from time to time. I tracked it down to the regexps in dm-validations.

http://github.com/datamapper/dm-more/blob/2cb0369f1853ed4aff32a3d3a...

The to_s here (line 20) will sometimes be in scientific notation. For example -0.00004 (-4.0e-05) so all the regexp validations futher down (~line 45 onwards) fail.

http://github.com/datamapper/dm-more/blob/2cb0369f1853ed4aff32a3d3a...

The two fixes I can think of are converting everything to BigDecimal and using .to_s('F') or adding an exponent alternative to each regexp. I'm happy to submit a patch for either (or if you have a better idea).

Comments and changes to this ticket

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 »

Referenced by

Pages