Class: Aho::Schema::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/aho/schema/validator.rb

Constant Summary collapse

TYPES =
{
  'string' => String,
  'number' => Numeric,
  'integer' => Integer,
  'boolean' => [TrueClass, FalseClass],
  'array' => Array,
  'object' => Hash
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(body, schema, parent_key = nil) ⇒ Validator

Returns a new instance of Validator.



15
16
17
18
19
# File 'lib/aho/schema/validator.rb', line 15

def initialize(body, schema, parent_key = nil)
  @body = body
  @schema = schema
  @parent_key = parent_key
end

Instance Method Details

#validate!Object



21
22
23
24
25
# File 'lib/aho/schema/validator.rb', line 21

def validate!
  validate_required_fields!
  validate_properties!
  true
end