Class: FutureValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
app/validators/future_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, _value) ⇒ Object



2
3
4
5
6
# File 'app/validators/future_validator.rb', line 2

def validate_each(record, attribute, _value)
  return unless record[attribute] < Time.now

  record.errors.add(attribute, :invalid, message: (options[:message] || 'must be in the future.'))
end