Class: RiderServer::Validate::Array
- Defined in:
- lib/rider_server/validate/array.rb
Instance Method Summary collapse
-
#initialize(element_validator) ⇒ Array
constructor
A new instance of Array.
- #validate(data, loc = "") ⇒ Object
Methods inherited from Base
Methods included from PredicateLogic
#add_predicate, #check_predicates
Constructor Details
#initialize(element_validator) ⇒ Array
Returns a new instance of Array.
15 16 17 |
# File 'lib/rider_server/validate/array.rb', line 15 def initialize(element_validator) @element_validator = element_validator end |
Instance Method Details
#validate(data, loc = "") ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/rider_server/validate/array.rb', line 19 def validate(data, loc = "") fail(data, loc, "be an array") unless data.is_a?(::Array) data.map.with_index do |element, index| @element_validator.validate(element, "#{loc}[#{index}]") end end |