Class: Grape::Validations::MutualExclusionValidator
- Defined in:
- lib/grape/validations/mutual_exclusion.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Attributes inherited from Validator
Instance Method Summary collapse
Methods inherited from Validator
convert_to_short_name, inherited, #initialize
Constructor Details
This class inherits a constructor from Grape::Validations::Validator
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
4 5 6 |
# File 'lib/grape/validations/mutual_exclusion.rb', line 4 def params @params end |
Instance Method Details
#validate!(params) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/grape/validations/mutual_exclusion.rb', line 6 def validate!(params) @params = params if two_or_more_exclusive_params_are_present raise Grape::Exceptions::Validation, params: keys_in_common, message_key: :mutual_exclusion end params end |