mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-25 15:22:58 +00:00
readme
This commit is contained in:
11
README.rdoc
11
README.rdoc
@@ -17,6 +17,8 @@ Validate dates, times and datetimes for Rails 3.x and ActiveModel.
|
|||||||
|
|
||||||
* Supports I18n for the error messages
|
* Supports I18n for the error messages
|
||||||
|
|
||||||
|
* Adds before_type_cast method on validated attributes
|
||||||
|
|
||||||
== INSTALLATION:
|
== INSTALLATION:
|
||||||
|
|
||||||
As plugin (from master)
|
As plugin (from master)
|
||||||
@@ -55,8 +57,15 @@ validation method
|
|||||||
|
|
||||||
class Person < ActiveRecord::Base
|
class Person < ActiveRecord::Base
|
||||||
validates_date :date_of_birth
|
validates_date :date_of_birth
|
||||||
|
# or
|
||||||
|
validates :date_of_birth, :timeliness => {:type => date}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# or even on a specific record, per ActiveModel API.
|
||||||
|
|
||||||
|
@person.validates_date :date_of_birth
|
||||||
|
|
||||||
|
|
||||||
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'
|
||||||
@@ -139,7 +148,7 @@ return nil in all other situations. Restrictions are skipped if they are nil.
|
|||||||
The plugin has some extensions to ActionView for allowing invalid
|
The plugin has some extensions to ActionView for allowing invalid
|
||||||
date and time values to be redisplayed to the user as feedback, instead of
|
date and time values to be redisplayed to the user as feedback, instead of
|
||||||
a blank field which happens by default in Rails. Though the date helpers make this a
|
a blank field which happens by default in Rails. Though the date helpers make this a
|
||||||
pretty rare occurence, given the select dropdowns for each date/time component, but
|
pretty rare occurrence, given the select dropdowns for each date/time component, but
|
||||||
it may be something of interest.
|
it may be something of interest.
|
||||||
|
|
||||||
To activate it, put this in an initializer:
|
To activate it, put this in an initializer:
|
||||||
|
|||||||
Reference in New Issue
Block a user