Class: JsonValidation::ValidatorCollection
- Inherits:
-
Object
- Object
- JsonValidation::ValidatorCollection
- Defined in:
- lib/json_validation/validator_collection.rb
Instance Method Summary collapse
-
#initialize(validators) ⇒ ValidatorCollection
constructor
A new instance of ValidatorCollection.
- #validate(record) ⇒ Object
Constructor Details
#initialize(validators) ⇒ ValidatorCollection
Returns a new instance of ValidatorCollection.
3 4 5 |
# File 'lib/json_validation/validator_collection.rb', line 3 def initialize(validators) @validators = validators end |
Instance Method Details
#validate(record) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/json_validation/validator_collection.rb', line 7 def validate(record) @validators.all? {|validator| if TYPES_TO_CLASSES[validator.class.type].any? {|klass| record.is_a?(klass)} validator.validate(record) else true end } end |