Class: SerialTranslator::SerialTranslatorPresenceValidator
- Inherits:
-
ActiveModel::Validations::PresenceValidator
- Object
- ActiveModel::Validations::PresenceValidator
- SerialTranslator::SerialTranslatorPresenceValidator
- Defined in:
- lib/serial_translator/serial_translator_presence_validator.rb
Instance Method Summary collapse
Instance Method Details
#kind ⇒ Object
11 12 13 |
# File 'lib/serial_translator/serial_translator_presence_validator.rb', line 11 def kind :presence end |
#validate_each(record, attribute, _value) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/serial_translator/serial_translator_presence_validator.rb', line 3 def validate_each(record, attribute, _value) translations = record.__send__("#{attribute}_translations") || {} return if translations.values.any?(&:present?) if record.send(attribute).blank? record.errors.add(attribute, :blank, **) end end |