Class: Schash::Schema::Rule::ArrayOf
- Defined in:
- lib/schash/schema/rule/array_of.rb
Instance Method Summary collapse
-
#initialize(rule) ⇒ ArrayOf
constructor
A new instance of ArrayOf.
- #validate(target, position = []) ⇒ Object
Methods inherited from Base
Constructor Details
Instance Method Details
#validate(target, position = []) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/schash/schema/rule/array_of.rb', line 13 def validate(target, position = []) errors = [] unless target.is_a?(Array) errors << Error.new(position, "is not an array") return errors end errors += target.each_with_index.map do |t, i| @rule.validate(t, position + [i]) end.flatten errors end |