
Nullable/required in auto-validations
Reported by Ashley Moran | June 30th, 2009 @ 02:14 AM | in 0.10.2
I believe that the current auto-validations system makes some misleading assumptions about how blank strings should be handled. I actually wrote this up as a blog post, because by the time I'd explained it to myself, I'd pretty much explained my interpretation of NULL.
I didn't think I'd get round to looking at this again soon, so while I'm on a ticket submission roll, I thought I'd post the blog article and generate a ticket around it, to gather feedback. I was going to reformat it and post the whole thing here, but that'd just delay it. And I'm lazy. So here's my original article (probably written around last November...)
http://aviewfromafar.net/2009/6/30/datamapper-properties-nullable-o...
Any thoughts?
Comments and changes to this ticket
-
Dan Kubb (dkubb) July 3rd, 2009 @ 02:59 AM
- Assigned user set to Dan Kubb (dkubb)
- State changed from new to accepted
@Ashley: I added a comment to your blog post. What do you think?
-
Dan Kubb (dkubb) August 18th, 2009 @ 02:30 PM
- Milestone changed from 0.10.0 to 0.10.1
-
Dan Kubb (dkubb) October 4th, 2009 @ 09:33 PM
- Milestone changed from 0.10.1 to 0.10.2
[project:id#20609 not-tagged:"0.10.0" not-tagged:"0.10.1" milestone:id#51895 bulk edit command]
-
DaNCeR October 18th, 2009 @ 11:24 PM
I agree with the proposed changes. IMO there is a lot of confusion generated by the ambiguity of the current API. This functionality is not incredibly important as there are several ways to get the required behaviour however I do believe that at the latest this needs to be taken care of before 1.0. If nobody has started work on this i'd be happy to work on it over the coming weeks.
-
Dan Kubb (dkubb) November 10th, 2009 @ 03:37 AM
I am working on this ticket and should have the dm-validations changes done tomorrow. dm-core changes will follow.
-
Dan Kubb (dkubb) November 10th, 2009 @ 04:00 PM
(from [05d6c8f0ee8a0e7426c4b7640cc1865b35d1bb29]) [dm-validations] Add :allow_blank option to validators
- Refactored logic testing allow_nil and allow_blank
- Refactored #call methods for validators to use a private #valid? method when possible, that performs the validator and returns true/false.
[#935] [#1058 state:resolved] http://github.com/datamapper/dm-more/commit/05d6c8f0ee8a0e7426c4b76...
-
Dan Kubb (dkubb) November 10th, 2009 @ 04:04 PM
I just committed some fixes to dm-validations to add allow_blank as an option.
The next step will be to update dm-core so that :nullable is deprecated, and :allow_nil and :allow_blank are added as options, and a :required option is added that sets both of them.
In the docs and deprecation warnings the :required option will be emphasized as an alternative to :nullable.
-
Dan Kubb (dkubb) November 10th, 2009 @ 06:59 PM
(from [f46c6ea9a02471c82bdd3256320373a878950f11]) Replaced :nullable option with :required in Property declarations
- The :required option reads much better than the word :nullable, and there was much confusion in the API, especially in dm-validations, around how :nullable should be mapped to the validations. Now that the options are consistent across the board it should be much simpler to map them.
- Added :allow_nil option in Property declaration. When true will allow the value to be nil.
- Added :allow_blank option in Property declaration. When true will allow the value to be blank.
- The :required option will set :allow_nil and :allow_blank. When :required is true, :allow_nil and :allow_blank will be set to false.
[#935] http://github.com/datamapper/dm-core/commit/f46c6ea9a02471c82bdd325...
-
Dan Kubb (dkubb) November 10th, 2009 @ 06:59 PM
(from [9ee32e4234f2ccaba791adb3a2c962b317fb3cd7]) [dm-more] Updated to use :required instead of :nullable for Property declarations
[#935] http://github.com/datamapper/dm-more/commit/9ee32e4234f2ccaba791adb...
-
Dan Kubb (dkubb) November 10th, 2009 @ 07:13 PM
(from [92033317564860be0a48efbe85bcc41d644c6b90]) [dm-validations] Validate presence only when Property#allow_blank? is true
[#935] http://github.com/datamapper/dm-more/commit/92033317564860be0a48efb...
-
Dan Kubb (dkubb) November 10th, 2009 @ 07:18 PM
- State changed from accepted to resolved
Ok, I think this is everything we talked about. I am going to mark this ticket as resolved.
Would someone be able to review all the commits and/or test this out with their app and confirm everything works as you'd expect? I'm pretty sure that will be the case, but I'd like confirmation from someone other than me.
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 »
People watching this ticket
Referenced by
-
1136 :nullable => false is NOT equivalent to :required => true @kristan: Ahh, I see what you mean. Actually, there was b...
-
1058 :nullable => false disallows blank strings Closing this ticket because the solution proposed in #935...
-
1097 Auto-validations not testing for blank strings correctly Now I'm sure that the expected behaviour for an empty str...
-
1097 Auto-validations not testing for blank strings correctly Work in progressing on this in #935. Marking this as dupl...
-
935 Nullable/required in auto-validations [#935] [#1058 state:resolved] http://github.com/datamapp...
-
1058 :nullable => false disallows blank strings [#935] [#1058 state:resolved] http://github.com/datamapp...
-
935 Nullable/required in auto-validations [#935] http://github.com/datamapper/dm-core/commit/f46c6...
-
935 Nullable/required in auto-validations [#935] http://github.com/datamapper/dm-more/commit/9ee32...
-
935 Nullable/required in auto-validations [#935] http://github.com/datamapper/dm-more/commit/92033...