spec/grape/api/custom_validations_spec.rb in grape-1.5.3 vs spec/grape/api/custom_validations_spec.rb in grape-1.6.0
- old
+ new
@@ -8,9 +8,10 @@
module CustomValidationsSpec
class DefaultLength < Grape::Validations::Base
def validate_param!(attr_name, params)
@option = params[:max].to_i if params.key?(:max)
return if params[attr_name].length <= @option
+
raise Grape::Exceptions::Validation.new(params: [@scope.full_name(attr_name)], message: "must be at the most #{@option} characters long")
end
end
end
end