New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add list validator #212
Add list validator #212
Conversation
b981355
to
6075f57
Compare
Rebased against 0.9.3pre2 |
@matthew342 sorry I haven't gotten back you on this. Been busy finishing off another branch. Should have time for it this weekend. |
@matthew342 Thanks for this PR, sorry it took me so long to get to it. I went to merge it, but its failing the specs when run in opal (bundle exec rake) Any chance you can see if you can figure out what's going on? |
No problem. Am a bit tied up for the next couple of days, but will take a On Wed, Jul 29, 2015 at 12:48 AM, Ryan Stout notifications@github.com
|
Just out of curiousity, what is a usecase for such a validator? |
6075f57
to
81570f4
Compare
Now should be ready to merge. Rebased on current master and fixed specs in Opal - it was the use of 'params' in a let() that apparently was causing the troubles. |
@dennym Any time you want to validate that a field is a value from an arbitrary list of possible values. |
@matthew342 Did you consider naming the validator inclusion_validator? validates :name, inclusion: { in: ['some', 'elements'] } This might be more intuitive for the people coming from rails |
@jfahrer No, hadn't crossed my mind but makes more sense that way. I'll update this weekend. |
…to add_validator
I had use for a validator that checks whether an attribute is included in a list of allowed values. I figure this is a pretty common need, so I thought I'd put in a PR.