Module: DynamicSchema::Validator

Extended by:
Validator
Included in:
Builder, Struct, Validator
Defined in:
lib/dynamic_schema/validator.rb

Instance Method Summary collapse

Instance Method Details

#valid?(values, schema: compiled_schema) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
# File 'lib/dynamic_schema/validator.rb', line 19

def valid?( values, schema: compiled_schema )
  traverse_and_validate_values( values, schema: schema ) do
    return false
  end
  true
end

#validate(values, schema: compiled_schema) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/dynamic_schema/validator.rb', line 11

def validate( values, schema: compiled_schema )
  errors = []
  traverse_and_validate_values( values, schema: schema ) { | error |
    errors << error
  }
  errors
end

#validate!(values, schema: compiled_schema) ⇒ Object



5
6
7
8
9
# File 'lib/dynamic_schema/validator.rb', line 5

def validate!( values, schema: compiled_schema )
  traverse_and_validate_values( values, schema: schema ) { | error |
    raise error
  }
end