doc tweaks

This commit is contained in:
Adam Meehan 2009-02-09 18:12:08 +11:00
parent 12aa78271e
commit 1181b725d0

View File

@ -51,11 +51,8 @@ validation method
end end
The list of validation methods available are as follows: The list of validation methods available are as follows:
* validates_date - validate value as date * validates_date - validate value as date
* validates_time - validate value as time only i.e. '12:20pm' * validates_time - validate value as time only i.e. '12:20pm'
* validates_datetime - validate value as a full date and time * validates_datetime - validate value as a full date and time
The validation methods take the usual options plus some specific ones to restrict The validation methods take the usual options plus some specific ones to restrict
@ -66,7 +63,7 @@ the valid range of dates or times allowed
:on_or_before - Attribute must be equal to or before this value to be valid :on_or_before - Attribute must be equal to or before this value to be valid
:after - Attribute must be after this value to be valid :after - Attribute must be after this value to be valid
:on_or_after - Attribute must be equal to or after this value to be valid :on_or_after - Attribute must be equal to or after this value to be valid
:between - Attribute must be between the values to be valid :between - Attribute must be between the values to be valid. Takes an array of two values or a range
Regular validation options: Regular validation options:
:allow_nil - Allow a nil value to be valid :allow_nil - Allow a nil value to be valid
@ -88,17 +85,17 @@ the valid range of dates or times allowed
:on_or_after_message :on_or_after_message
:between_message :between_message
The temporal restrictions can take 4 different value types: The temporal restrictions, with_date and with_time can take 4 different value types:
* String value * String value
* Date, Time, or DateTime object value * Date, Time, or DateTime object value
* Proc or lambda object * Proc or lambda object which may take an optional parameter being the record object
* A symbol matching the method name in the model * A symbol matching the method name in the model
* Between option takes an array of two values or a range
When an attribute value is compared to temporal restrictions, they are compared as When an attribute value is compared to temporal restrictions, they are compared as
the same type as the validation method type. So using validates_date means all the same type as the validation method type. So using validates_date means all
values are compared as dates. values are compared as dates. This s except in the case of with_time and with_date
options which effectively force the value to validated as a datetime against the
temporal options.
== EXAMPLES: == EXAMPLES:
@ -112,6 +109,8 @@ values are compared as dates.
validates_datetime :appointment_date, :before => Proc.new { 1.week.from_now } validates_datetime :appointment_date, :before => Proc.new { 1.week.from_now }
validates_datetime :appointment_date, :before => Proc.new { 1.week.from_now }
validates_date :entry_date, :with_time => '17:00', :on_or_before => :competition_closing validates_date :entry_date, :with_time => '17:00', :on_or_before => :competition_closing