mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-23 06:16:44 +00:00
Date and time validation plugin for ActiveModel and Rails. Supports multiple ORMs and allows custom date/time formats.
| lib | ||
| spec | ||
| init.rb | ||
| Rakefile | ||
| README | ||
= validates_timeliness
* Source: http://github.com/adzap/validates_timeliness
* Tickets: http://adzap.lighthouseapp.com/projects/14111-validates_timeliness
== DESCRIPTION
Validate dates, times and datetimes for Rails 2.x. Plays nicely with new
features such as automatic timezone handling and dirty attributes. Allows
date/time atttributes to behave like other attribute types by allowing you to
review the raw entered value before it is converted.
== FEATURES/PROBLEMS
* Adds ActiveRecord validation for dates, times and datetimes
* Adds better transparency of date/time attributes restoring ability to view
raw value before type casting, which was lost in Rails 2.1 to get the better
timezone features.
* Allows pluggable date and time parsing with other parsers of your choosing (eg Chronic)
* Respects timezone features of both Rails 2.0 and 2.1.
== INSTALLATION
Rails 2.1
./script/plugin git://github.com/adzap/validates_timeliness
Rails 2.0
== USAGE
To validate a model with a date, time or datetime attribute you just use the
validation method
class Person < ActiveRecord::Base
validates_timeliness_of :date_of_birth
end
But for a more semantic validation method you can use the specific validation
for the attribute type. The type based validation methods are
* validates_date
* validates_time
* validates_datetime
If the value for a date attribute contains a time, it will be ignored when
validating. The same is true to time attributes which ignore the date.
The default valid formats for a date or datetime field are those supported by
the Ruby ParseDate library
(http://www.ruby-doc.org/docs/ProgrammingRuby/html/lib_standard.html#ParseDate.parsedate).
The validation method has the usual options plus some specific ones to restrict
the valid range
Options:
- allow_nil
- allow_blank
- before
- on_or_before
- after
- on_or_after
- type
MUCH MORE DOCS TO COME