Class: SomeValidator
- Defined in:
- lib/errgonomic/rails/active_record_optional.rb
Overview
Validates that an attribute is there at all, where presence asks whether it amounts to anything: an empty string is a value, nil and None are not. Lifting the value means the same question can be asked of a model the concern never converted.
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
416 417 418 |
# File 'lib/errgonomic/rails/active_record_optional.rb', line 416 def validate_each(record, attribute, value) record.errors.add(attribute, 'is invalid') unless value.to_option.some? end |