mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-23 06:16:44 +00:00
readme tweaks
This commit is contained in:
parent
ea082b5258
commit
8b199b3f10
@ -63,7 +63,7 @@ another ORM then look at the {wiki page}[http://github.com/adzap/validates_timel
|
|||||||
|
|
||||||
validates_datetime :finish_time, :after => :start_time # Method symbol
|
validates_datetime :finish_time, :after => :start_time # Method symbol
|
||||||
|
|
||||||
validates_date :booked_at, :on => :create, :on_or_after => :today # See Restriction Option Shorthand.
|
validates_date :booked_at, :on => :create, :on_or_after => :today # See Restriction Shorthand.
|
||||||
validates_time :booked_at, :between => ['9.00am', '5:00pm']
|
validates_time :booked_at, :between => ['9.00am', '5:00pm']
|
||||||
|
|
||||||
validates_time :breakfast_time, :on_or_after => '6:00am',
|
validates_time :breakfast_time, :on_or_after => '6:00am',
|
||||||
@ -78,9 +78,9 @@ To validate a model with a date, time or datetime attribute you just use the
|
|||||||
validation method
|
validation method
|
||||||
|
|
||||||
class Person < ActiveRecord::Base
|
class Person < ActiveRecord::Base
|
||||||
validates_date :date_of_birth, :on_or_before => :today
|
validates_date :date_of_birth, :on_or_before => lambda { Date.today }
|
||||||
# or
|
# or
|
||||||
validates :date_of_birth, :timeliness => {:on_or_before => :today, :type => date}
|
validates :date_of_birth, :timeliness => {:on_or_before => lambda { Date.today }, :type => date}
|
||||||
end
|
end
|
||||||
|
|
||||||
# or even on a specific record, per ActiveModel API.
|
# or even on a specific record, per ActiveModel API.
|
||||||
@ -178,7 +178,7 @@ By default the parser is switched off. To switch it on:
|
|||||||
See the wiki[http://github.com/adzap/validates_timeliness/wiki/Plugin-Parser] for all the details about the parser.
|
See the wiki[http://github.com/adzap/validates_timeliness/wiki/Plugin-Parser] for all the details about the parser.
|
||||||
|
|
||||||
|
|
||||||
=== Restriction Option Shorthand
|
=== Restriction Shorthand
|
||||||
|
|
||||||
It is common to restrict an attribute to being on or before the current time or current day.
|
It is common to restrict an attribute to being on or before the current time or current day.
|
||||||
To specify this you need to use a lambda as an option value e.g. <tt>lambda { Time.now }</tt>.
|
To specify this you need to use a lambda as an option value e.g. <tt>lambda { Time.now }</tt>.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user