Class: API::Validations::Validators::Limit

Inherits:
Grape::Validations::Base
  • Object
show all
Defined in:
lib/api/validations/validators/limit.rb

Instance Method Summary collapse

Instance Method Details

#validate_param!(attr_name, params) ⇒ Object

Raises:

  • (Grape::Exceptions::Validation)

7
8
9
10
11
12
13
14
15
# File 'lib/api/validations/validators/limit.rb', line 7

def validate_param!(attr_name, params)
  value = params[attr_name]

  return if value.size <= @option

  raise Grape::Exceptions::Validation,
    params: [@scope.full_name(attr_name)],
    message: "#{@scope.full_name(attr_name)} must be less than #{@option} characters"
end