grape: Params validations do not run for route_param
Hi, I found that validations do not run for route_param, here is a minimal example:
# file: route_param.ru
require 'grape'
class Bang < Grape::Validations::Base
def validate_param!(attr_name, params)
fail Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message: 'bang'
end
end
class RouteParam < Grape::API
format :json
default_format :json
params do
requires :name, type: String, bang: true
end
route_param :name do
get do
present :name, params[:name]
end
end
end
run RouteParam
Run with rackup route_param.ru and then curl localhost:9292/foo.
I expect a validation failed message, but instead I get {"name":"foo"}.
I am using version 0.14.0.
Updated: fix sample code typos
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 17 (14 by maintainers)
@dblock As I promise previously I create pull request with specs for issue about I told you. Also I find one more bug in
declaredbehaviour. Everything is here - https://github.com/ruby-grape/grape/pull/1430 @namusyaka I think you should also check this pull request.