Class: Kangaru::Validation::ModelValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/kangaru/validation/model_validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#modelObject (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