Class: API::Validations::Validators::CheckAssigneesCount
- Inherits:
-
Grape::Validations::Validators::Base
- Object
- Grape::Validations::Validators::Base
- API::Validations::Validators::CheckAssigneesCount
- Defined in:
- lib/api/validations/validators/check_assignees_count.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.coerce ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/api/validations/validators/check_assignees_count.rb', line 7 def self.coerce ->(value) do case value when String, Array Array.wrap(value) else [] end end end |
Instance Method Details
#validate_param!(attr_name, params) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/api/validations/validators/check_assignees_count.rb', line 18 def validate_param!(attr_name, params) return if param_allowed?(attr_name, params) raise Grape::Exceptions::Validation.new( params: [@scope.full_name(attr_name)], message: "allows one value, but found #{params[attr_name].size}: #{params[attr_name].join(', ')}" ) end |