Class: VCAP::JsonSchema::ArraySchema
- Inherits:
-
BaseSchema
- Object
- BaseSchema
- VCAP::JsonSchema::ArraySchema
- Defined in:
- lib/vcap/json_schema.rb
Overview
Checks that supplied value is an array, and each value in the array validates
Instance Attribute Summary collapse
-
#item_schema ⇒ Object
Returns the value of attribute item_schema.
Instance Method Summary collapse
-
#initialize(schema) ⇒ ArraySchema
constructor
A new instance of ArraySchema.
- #validate(dec_json) ⇒ Object
Constructor Details
#initialize(schema) ⇒ ArraySchema
Returns a new instance of ArraySchema.
87 88 89 90 |
# File 'lib/vcap/json_schema.rb', line 87 def initialize(schema) raise ArgumentError, "You must supply a schema, #{schema.class} given" unless schema.kind_of?(BaseSchema) @item_schema = schema end |
Instance Attribute Details
#item_schema ⇒ Object
Returns the value of attribute item_schema.
85 86 87 |
# File 'lib/vcap/json_schema.rb', line 85 def item_schema @item_schema end |
Instance Method Details
#validate(dec_json) ⇒ Object
92 93 94 95 96 97 |
# File 'lib/vcap/json_schema.rb', line 92 def validate(dec_json) raise TypeError, "Expected instance of Array, #{dec_json.class} given" unless dec_json.kind_of?(Array) for v in dec_json @item_schema.validate(v) end end |