This project is archived and is in readonly mode.
validates_inclusion/exclusion_of should also accept a symbol or proc as the :in/:within option
-
Chris Cherry
+1
This seems like a very useful addition, in fact I'm kinda surprised its not there already. The example he gives above is a pretty good demonstration of where it could be applied, checking for the existence of the value of the parent_id attribute in a dynamic set.
Tests relating to this change pass.
-
Pratik
- State changed from new to incomplete
I like this as well. A few changes before it can be pushed :
- Missing ActiveModel tests
- Missing tests for validates_exclusion_of
- I don't like 'case enum.class.to_s'. It should just use 'case enum'
-
shuber
Updated patch - uses 'case enum' instead of 'case enum.class.to_s'
-
Stephan Kaag
+1
-
Dan Pickett
- Tag changed from activemodel, activerecord, edge, patch, tested, validations to activemodel, activerecord, bugmash, edge, patch, tested, validations
-
Dan Pickett
- No changes were found…
-
Santiago Pastorino
- State changed from incomplete to open
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino
- State changed from open to stale
-
pmontrasio
- Tag cleared.
It seems that shuber's patch didn't make it into Rails 3. Too bad because I was looking for a way to validate against some dynamic value. I'll fall back to writing a custom validator but it takes more code to do that.
