Class: ATDIS::Validators::FilledArrayValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- ATDIS::Validators::FilledArrayValidator
- Defined in:
- lib/atdis/validators.rb
Overview
Can’t be an empty array
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/atdis/validators.rb', line 59 def validate_each(record, attribute, value) if value && !value.kind_of?(Array) = "should be an array" = ErrorMessage[, [:spec_section]] if [:spec_section] record.errors.add(attribute, ) end if value && value.kind_of?(Array) && value.empty? = "should not be an empty array" = ErrorMessage[, [:spec_section]] if [:spec_section] record.errors.add(attribute, ) end end |