Class: JsonValidation::ValidatorCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/json_validation/validator_collection.rb

Instance Method Summary collapse

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