Skip to content

Fix Proc with arity one in param values #613

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

Merged
merged 2 commits into from
Jun 12, 2017

Conversation

timothysu
Copy link
Contributor

@timothysu timothysu commented May 30, 2017

Recently ran into an issue where having custom validations in values would cause documentation generation to fail. This simply mitigates an error from occurring.


From https://github.com/ruby-grape/grape/blob/master/README.md :

Alternatively, a Proc with arity one (i.e. taking one argument) can be used to explicitly validate
each parameter value. In that case, the Proc is expected to return a truthy value if the parameter
value is valid.

params do
  requires :number, type: Integer, values: ->(v) { v.even? && v < 25 }
end

@timothysu timothysu force-pushed the bugfix/values-proc-with-arg branch from 120a76f to d90082f Compare May 30, 2017 20:40
@coveralls
Copy link

coveralls commented May 30, 2017

Coverage Status

Coverage remained the same at 97.642% when pulling eabe736 on salsify:bugfix/values-proc-with-arg into 91e8210 on ruby-grape:master.

@LeFnord
Copy link
Member

LeFnord commented Jun 12, 2017

thanks @timothysu and sorry for the late mörge

@LeFnord LeFnord merged commit e6a8065 into ruby-grape:master Jun 12, 2017
LeFnord pushed a commit to LeFnord/grape-swagger that referenced this pull request Feb 9, 2019
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