Class: FutureDateValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- FutureDateValidator
- Defined in:
- app/validators/future_date_validator.rb
Overview
Validates that a date is in the future.
Example:
class Member < ActiveRecord::Base
validates :expires_at, allow_blank: true, future_date: true
end
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
14 15 16 |
# File 'app/validators/future_date_validator.rb', line 14 def validate_each(record, attribute, value) record.errors.add(attribute, _('cannot be a date in the past')) if value < Date.current end |