
validation for ":length => (1..100)" broken when field = nil
Reported by Liam Morley (carpeliam) | November 10th, 2008 @ 11:43 AM
This is with dm-validations 0.9.6, not sure if it's fixed since then.
I have a class with "property :title, String, :length => (2..100)". my_obj.valid? returns false when title equals 'a', but returns true when title equals nil. It should return false in both circumstances.
It looks like it's only broken when the length is part of the property declaration - if I have "validates_length :title, :in => (1..100)" on a separate line, then my_obj.valid? correctly returns false when title is nil. Anybody using the validation as part of the property declaration could consider this a workaround.
Comments and changes to this ticket
-
Dan Kubb (dkubb) January 8th, 2009 @ 02:19 PM
- State changed from new to unconfirmed
- Assigned user cleared.
-
Dan Kubb (dkubb) January 8th, 2009 @ 02:46 PM
- Assigned user set to Michael Klishin (antares)
-
Michael Klishin (antares) January 13th, 2009 @ 05:53 AM
- State changed from unconfirmed to resolved
Liam,
I added a test case and cleaned up the spec suite a bit, see 32960c656edce in dm-more. Example passes just fine on HEAD. Let me know if it is incorrect or something, I will reopen.
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.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »