Class: Kangaru::Validation::ModelValidator
- Inherits:
-
Object
- Object
- Kangaru::Validation::ModelValidator
- Defined in:
- lib/kangaru/validation/model_validator.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
-
#initialize(model:) ⇒ ModelValidator
constructor
A new instance of ModelValidator.
- #validate!(**rules) ⇒ Object
Constructor Details
#initialize(model:) ⇒ ModelValidator
Returns a new instance of ModelValidator.
6 7 8 |
# File 'lib/kangaru/validation/model_validator.rb', line 6 def initialize(model:) @model = model end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
4 5 6 |
# File 'lib/kangaru/validation/model_validator.rb', line 4 def model @model end |
Instance Method Details
#validate!(**rules) ⇒ Object
10 11 12 13 14 |
# File 'lib/kangaru/validation/model_validator.rb', line 10 def validate!(**rules) rules.each do |attribute, validations| validate_attribute!(attribute, validations) end end |