Class: ActiveModel::Validations::PresenceOfFlagsValidator
- Inherits:
-
EachValidator
- Object
- EachValidator
- ActiveModel::Validations::PresenceOfFlagsValidator
- Defined in:
- lib/flag_shih_tzu/validators.rb
Overview
A simple EachValidator that will check for the presence of the flags specified
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
20 21 22 23 24 |
# File 'lib/flag_shih_tzu/validators.rb', line 20 def validate_each(record, attribute, value) value = record.send(:read_attribute_for_validation, attribute) check_flag(record, attribute) record.errors.add(attribute, :blank, ) if value.blank? || value == 0 end |