Using allow_blank validator for the required parameter may lead to two validation errors, but I expected to have only one.
Example:
requires :customer_key, type: String, allow_blank: false
If there is no customer_key parameter in request then we receive the following Grape::Exceptions::ValidationErrors exception:
error
=> #<Grape::Exceptions::ValidationErrors: Grape::Exceptions::ValidationErrors>
error.errors
=> {["customer_key"]=>[#<Grape::Exceptions::Validation: is missing>, #<Grape::Exceptions::Validation: is empty>]}
So we receive
- one error because the required parameter "is missing" and
- another one caused by
allow_blank validator because the parameter "is empty"
The second error (produced by the allow_blank) doesn't make sense and looks a bit annoying. The expected behavior is to receive only "is missing" error.