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 test_with option to values validator #1568

Merged
merged 1 commit into from
Feb 1, 2017

Conversation

jlfaber
Copy link
Contributor

@jlfaber jlfaber commented Jan 31, 2017

This PR adds a new option test_with to the values validator. If present, it must be a Proc that accepts a single argument (the param value) and returns a truthy value if the argument is valid.

I don't think this has been explicitly asked for, and one could certainly do the same thing using a custom validator. But this seemed a little more convenient for simple validations that aren't already handled by the existing built-ins.

This could be an acceptable workaround/solution for #1535 which requests the ability to specify a maximum parameter value.

@dblock
Copy link
Member

dblock commented Jan 31, 2017

Quick thought. Maybe test_with could be compare_with or proc?

@coveralls
Copy link

coveralls commented Jan 31, 2017

Coverage Status

Coverage decreased (-0.007%) to 99.067% when pulling a354dbd on jlfaber:check_with into 081d09b on ruby-grape:master.

12 similar comments
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.007%) to 99.067% when pulling a354dbd on jlfaber:check_with into 081d09b on ruby-grape:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.007%) to 99.067% when pulling a354dbd on jlfaber:check_with into 081d09b on ruby-grape:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.007%) to 99.067% when pulling a354dbd on jlfaber:check_with into 081d09b on ruby-grape:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.007%) to 99.067% when pulling a354dbd on jlfaber:check_with into 081d09b on ruby-grape:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.007%) to 99.067% when pulling a354dbd on jlfaber:check_with into 081d09b on ruby-grape:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.007%) to 99.067% when pulling a354dbd on jlfaber:check_with into 081d09b on ruby-grape:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.007%) to 99.067% when pulling a354dbd on jlfaber:check_with into 081d09b on ruby-grape:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.007%) to 99.067% when pulling a354dbd on jlfaber:check_with into 081d09b on ruby-grape:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.007%) to 99.067% when pulling a354dbd on jlfaber:check_with into 081d09b on ruby-grape:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.007%) to 99.067% when pulling a354dbd on jlfaber:check_with into 081d09b on ruby-grape:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.007%) to 99.067% when pulling a354dbd on jlfaber:check_with into 081d09b on ruby-grape:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.007%) to 99.067% when pulling a354dbd on jlfaber:check_with into 081d09b on ruby-grape:master.

@jlfaber
Copy link
Contributor Author

jlfaber commented Feb 1, 2017

Fair point. Not in love with compare_with as it's not necessarily a compare. I kind of like proc though. I'll tweak that and repush.

@coveralls
Copy link

coveralls commented Feb 1, 2017

Coverage Status

Coverage increased (+0.03%) to 99.104% when pulling 5d520ba on jlfaber:check_with into 081d09b on ruby-grape:master.

@jlfaber
Copy link
Contributor Author

jlfaber commented Feb 1, 2017

Renamed test_with to proc and cleaned up some unused test code to (slightly) improve coverage.

@dblock dblock merged commit d124df7 into ruby-grape:master Feb 1, 2017
@dblock
Copy link
Member

dblock commented Feb 1, 2017

Looks great, merged.

@jlfaber jlfaber deleted the check_with branch February 1, 2017 16:20
@jlfaber jlfaber mentioned this pull request Feb 1, 2017
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.

3 participants