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

Boolean validation failed #1002

Closed
hidogcat opened this issue Apr 27, 2015 · 3 comments
Closed

Boolean validation failed #1002

hidogcat opened this issue Apr 27, 2015 · 3 comments
Labels

Comments

@hidogcat
Copy link

Hi there,
There is a defect about validation, for example:
WHEN
params: some_name do
xxx
requires :some_symbol, type: Grape::API::Boolean, allow_blank: false
xxx
end
THEN
send the request with some_symbol = false
GOT
a bad request with "error": "some_name[some_symbol] is empty"

This happened when allow_blank is false

Best regards,
Zhijia

@dblock
Copy link
Member

dblock commented Apr 27, 2015

Please try to write a spec for this?

@dblock dblock added the bug? label Apr 27, 2015
@mfunaro
Copy link
Contributor

mfunaro commented May 5, 2015

I've noticed this too. I believe it's because the allow_blank validator is using the rails present? method which will treat false as not present and therefore fail the validation.

I forked the repo and added a failing test here https://github.com/mfunaro/grape/blob/master/spec/grape/validations/validators/allow_blank_spec.rb

Pull request for fix here #1012

@dm1try
Copy link
Member

dm1try commented Jun 9, 2015

Fixed in #1012

@dm1try dm1try closed this as completed Jun 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants