Class: Aspect::Validator
- Inherits:
-
Object
- Object
- Aspect::Validator
- Defined in:
- lib/aspect/validator.rb
Overview
Verify a set of checks on a list of an object’s attributes.
Uses a Verifier for each attribute run the checks.
Instance Method Summary collapse
-
#initialize ⇒ Validator
constructor
A new instance of Validator.
- #validate(object) ⇒ Object
- #verify(attributes = {}) ⇒ Object
Constructor Details
#initialize ⇒ Validator
Returns a new instance of Validator.
92 93 94 |
# File 'lib/aspect/validator.rb', line 92 def initialize @verifications = [] end |
Instance Method Details
#validate(object) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/aspect/validator.rb', line 100 def validate(object) errors = Errors.new @verifications.each do |constraint| value = object.send(constraint.name) errors = constraint.validate(value) # errors.add() # TODO end errors end |
#verify(attributes = {}) ⇒ Object
96 97 98 |
# File 'lib/aspect/validator.rb', line 96 def verify(attributes={}) @verifications << Verifier.new(attributes) end |