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

Custom validator shouldn't be triggered when optional and not present #211

Closed
adamgotterer opened this issue Jul 25, 2012 · 0 comments · Fixed by #212
Closed

Custom validator shouldn't be triggered when optional and not present #211

adamgotterer opened this issue Jul 25, 2012 · 0 comments · Fixed by #212

Comments

@adamgotterer
Copy link
Contributor

params do
  optional :some_param, type: Integer, custom_validator: true
end

When :some_param is not present and a custom validator is set; the custom validator will automatically be called, despite the optional setting. It seems the desired behavior when using optional would be to only call the custom validator when the param is present.

adamgotterer added a commit to adamgotterer/grape that referenced this issue Jul 26, 2012
…ional and not present

Updated validator to only run custom optional validation when the param
is present. Re-wrote validations_spec to be a little more robust.
 Added section to documentation for custom validation.
@dblock dblock closed this as completed in 1bcbfb0 Jul 30, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants