Class: Inspector::Constraint::Validators::Validity
- Inherits:
-
Object
- Object
- Inspector::Constraint::Validators::Validity
- Defined in:
- lib/inspector/constraint/validators/validity.rb
Instance Method Summary collapse
-
#initialize(validator) ⇒ Validity
constructor
A new instance of Validity.
- #validate(value, constraint, violations_list) ⇒ Object
Constructor Details
#initialize(validator) ⇒ Validity
Returns a new instance of Validity.
5 6 7 |
# File 'lib/inspector/constraint/validators/validity.rb', line 5 def initialize(validator) @validator = validator end |
Instance Method Details
#validate(value, constraint, violations_list) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/inspector/constraint/validators/validity.rb', line 9 def validate(value, constraint, violations_list) violations = @validator.validate(value, :as => constraint.validate_as(value)) if constraint.positive? violations.violations.each { |violation| violations_list << violation } violations.children.each { |path, list| violations_list[path] = list } else if violations.empty? violations_list << Constraint::Violation.new(constraint) end end end |