grape
grape copied to clipboard
Error in AsValidator when using nested parameters
Possible fix is to rescue all errors and re-raise as a Grape::Exceptions::Validation
.
module Grape
module Validations
class AsValidator < Base
def initialize(attrs, options, required, scope, opts = {})
@renamed_options = options
super
end
def validate_param!(attr_name, params)
params[@renamed_options] = params[attr_name]
rescue StandardError => _e
raise Grape::Exceptions::Validation.new(
params: [@scope.full_name(attr_name)],
message: message(:invalid_format),
)
end
end
end
end
Please PR a spec + this?