class Length < Grape::Validations::Base def validate_param!(attr_name, params) return true if params[attr_name].blank? unless params[attr_name].length <= @option raise Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message: I18n.t( "grape.errors.format", attributes: attr_name, message: I18n.t( "grape.errors.messages.too_long",count: @option, default: "must be at the most #{@option} characters long" ) ) end end end