Class: Kangaru::Validation::AttributeValidator
- Inherits:
-
Object
- Object
- Kangaru::Validation::AttributeValidator
- Defined in:
- lib/kangaru/validation/attribute_validator.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
-
#initialize(model:, attribute:) ⇒ AttributeValidator
constructor
A new instance of AttributeValidator.
- #validate!(**validations) ⇒ Object
Constructor Details
#initialize(model:, attribute:) ⇒ AttributeValidator
Returns a new instance of AttributeValidator.
8 9 10 11 |
# File 'lib/kangaru/validation/attribute_validator.rb', line 8 def initialize(model:, attribute:) @model = model @attribute = attribute end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
6 7 8 |
# File 'lib/kangaru/validation/attribute_validator.rb', line 6 def attribute @attribute end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
6 7 8 |
# File 'lib/kangaru/validation/attribute_validator.rb', line 6 def model @model end |
Instance Method Details
#validate!(**validations) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/kangaru/validation/attribute_validator.rb', line 13 def validate!(**validations) validations.each do |validator, params| params = {} if params == true load_validator(validator:, **params).validate end end |