Date and time validation plugin for ActiveModel and Rails. Supports multiple ORMs and allows custom date/time formats.
Go to file
2008-07-17 16:25:54 +10:00
lib moved format proc helper methods into formats module so they work 2008-07-17 16:25:54 +10:00
spec moved format proc helper methods into formats module so they work 2008-07-17 16:25:54 +10:00
benchmark.rb moved formats to own module 2008-07-17 15:08:33 +10:00
init.rb added specs for validation 2008-05-03 15:52:40 +10:00
Rakefile added default task 2008-07-08 10:37:54 +10:00
README a little more docs 2008-07-11 17:42:10 +10:00

= 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