Class: Quby::AttributeValidValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- Quby::AttributeValidValidator
- Defined in:
- lib/active_model_modules/attribute_valid_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
2 3 4 5 6 7 8 9 |
# File 'lib/active_model_modules/attribute_valid_validator.rb', line 2 def validate_each(record, attribute, value) return if value.blank? if value.respond_to?(:valid?) record.errors.add(attribute, value.errors..join(', ')) unless value.valid? else record.errors.add(attribute, 'does not respond_to valid?') end end |