Class: SomeValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/errgonomic/rails/active_record_optional.rb

Overview

Validates that an Option attribute is Some, analogous to a presence validation on a plain attribute.

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



67
68
69
# File 'lib/errgonomic/rails/active_record_optional.rb', line 67

def validate_each(record, attribute, value)
  record.errors.add(attribute, 'is invalid') unless value.some?
end