Method: ATValidations::Predicates#atv_array_of
- Defined in:
- lib/at-validations.rb
#atv_array_of(predicate) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/at-validations.rb', line 54 def atv_array_of(predicate) atv_union( atv_instance_of(Array), atv_block do |e| errs = {} e.each_index {|i| err = predicate.call(e); errs[i] = err unless true == err } errs.count == 0 || Error.new(:error => 'array contains elements which do not match predicate', :failures => errs) end ) end |