Class: Chronicle::Schema::Validation::Validator
- Inherits:
-
Object
- Object
- Chronicle::Schema::Validation::Validator
- Defined in:
- lib/chronicle/schema/validation/validator.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.call(data) ⇒ Object
17 18 19 |
# File 'lib/chronicle/schema/validation/validator.rb', line 17 def self.call(data) new.validate(data) end |
Instance Method Details
#validate(data) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/chronicle/schema/validation/validator.rb', line 5 def validate(data) type = data[:@type] || data['@type'] raise Chronicle::Schema::ValidationError, 'Data does not contain a typed object' unless type contract = Chronicle::Schema::Validation.get_contract(type.to_sym) # binding.pry unless contract raise Chronicle::Schema::ValidationError, "#{type} is not a valid type" unless contract contract.new.call(data) end |