Module: SimpleParams::Validations
- Extended by:
- ActiveModel::Validations
- Included in:
- Params
- Defined in:
- lib/simple_params/concerns/validations.rb
Instance Method Summary collapse
Instance Method Details
#valid?(context = nil) ⇒ Boolean
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/simple_params/concerns/validations.rb', line 7 def valid?(context = nil) current_context, self.validation_context = validation_context, context errors.clear run_validations! # Make sure that nested classes are also valid nested_classes_valid? && errors.empty? ensure self.validation_context = current_context end |
#validate! ⇒ Object
18 19 20 21 22 |
# File 'lib/simple_params/concerns/validations.rb', line 18 def validate! unless valid? raise SimpleParamsError, self.errors.to_hash.to_s end end |