Class: LIVR::Rules::Meta::ListOf
- Inherits:
-
LIVR::Rule
- Object
- LIVR::Rule
- LIVR::Rules::Meta::ListOf
- Defined in:
- lib/livr/rules/meta.rb
Instance Method Summary collapse
- #call(values, user_data, field_results) ⇒ Object
-
#initialize(*rules) ⇒ ListOf
constructor
A new instance of ListOf.
Constructor Details
Instance Method Details
#call(values, user_data, field_results) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/livr/rules/meta.rb', line 58 def call(values, user_data, field_results) return if is_no_value(values) return 'FORMAT_ERROR' unless values.is_a?(Array) results = [] errors = [] has_errors = false values.each do |value| result = @validator.validate(field: value) if result results << result[:field] errors << nil else has_errors = true errors << @validator.get_errors[:field] results << nil end end if has_errors return errors else field_results << results return end end |