Class: Hashidator
- Inherits:
-
Object
- Object
- Hashidator
- Defined in:
- lib/hashidator.rb,
lib/hashidator/version.rb
Constant Summary collapse
- VERSION =
"0.4.1"
Instance Attribute Summary collapse
-
#schema ⇒ Object
Returns the value of attribute schema.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(schema) ⇒ Hashidator
constructor
A new instance of Hashidator.
- #validate(input) ⇒ Object
Constructor Details
#initialize(schema) ⇒ Hashidator
Returns a new instance of Hashidator.
10 11 12 |
# File 'lib/hashidator.rb', line 10 def initialize(schema) @schema = schema end |
Instance Attribute Details
#schema ⇒ Object
Returns the value of attribute schema.
8 9 10 |
# File 'lib/hashidator.rb', line 8 def schema @schema end |
Class Method Details
.validate(schema, input) ⇒ Object
4 5 6 |
# File 'lib/hashidator.rb', line 4 def self.validate(schema, input) new(schema).validate(input) end |
Instance Method Details
#validate(input) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/hashidator.rb', line 14 def validate(input) input ||= {} schema.all? {|key, validator| validate_value(validator, input[key]) } end |