Class: AssetBoxPresenceValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- AssetBoxPresenceValidator
- Defined in:
- lib/validators/asset_box_presence_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
2 3 4 5 |
# File 'lib/validators/asset_box_presence_validator.rb', line 2 def validate_each(record, attribute, value) num_in_box = (record. || []).select { || .box == attribute.to_s.pluralize && .marked_for_destruction? == false }.size record.errors[attribute] << "can't be blank" if num_in_box == 0 end |