Module: ActiveModel::Validations::HelperMethods
- Defined in:
- lib/active_model/validations/date_validator.rb
Instance Method Summary collapse
-
#validates_date_of(*attr_names) ⇒ Object
Validates whether the value of the specified attribute is a validate Date.
Instance Method Details
#validates_date_of(*attr_names) ⇒ Object
Validates whether the value of the specified attribute is a validate Date
class Person < ActiveRecord::Base
validates_date_of :payment_date, :after => :packaging_date
validates_date_of :expiration_date, :before => Proc.new { Time.now }
end
Configuration options:
-
:after
- check that a Date is after the specified one. -
:before
- check that a Date is before the specified one. -
:after_or_equal_to
- check that a Date is after or equal to the specified one. -
:before_or_equal_to
- check that a Date is before or equal to the specified one.
116 117 118 |
# File 'lib/active_model/validations/date_validator.rb', line 116 def validates_date_of(*attr_names) validates_with DateValidator, _merge_attributes(attr_names) end |