Skip to content
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

Closed
wants to merge 9 commits into from
Closed

Conversation

matthew342
Copy link
Contributor

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.

@matthew342 matthew342 force-pushed the add_validator branch 2 times, most recently from b981355 to 6075f57 Compare May 26, 2015 22:51
@matthew342
Copy link
Contributor Author

Rebased against 0.9.3pre2

@ryanstout
Copy link
Member

@matthew342 sorry I haven't gotten back you on this. Been busy finishing off another branch. Should have time for it this weekend.

@ryanstout
Copy link
Member

@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?

@matthew342
Copy link
Contributor Author

No problem. Am a bit tied up for the next couple of days, but will take a
look early next week.

On Wed, Jul 29, 2015 at 12:48 AM, Ryan Stout notifications@github.com
wrote:

@matthew342 https://github.com/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?


Reply to this email directly or view it on GitHub
#212 (comment).

@dennym
Copy link
Contributor

dennym commented Aug 1, 2015

Just out of curiousity, what is a usecase for such a validator?

@matthew342
Copy link
Contributor Author

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.

@matthew342
Copy link
Contributor Author

@dennym Any time you want to validate that a field is a value from an arbitrary list of possible values.

@jfahrer
Copy link
Contributor

jfahrer commented Aug 10, 2015

@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

@matthew342
Copy link
Contributor Author

@jfahrer No, hadn't crossed my mind but makes more sense that way. I'll update this weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants