ValidatesAsDateTime
This Ruby on Rails gem/plugin implements an ActiveRecord validation helper called validates_as_date_time which validates U.S. dates, times, or date-times.
Installation:
gem sources -a gems.github.com
Install the gem(s): sudo gem install gbdev-validates_as_date_time
Add to environment.rb initializer block: config.gem ‘gbdev-validates_as_date_time’, :version => ‘>=0.5.0’, :lib => ‘validates_as_date_time’, :source => ‘gems.github.com’
Usage:
In your model file do something like:
class MyClass < ActiveRecord::Base
validates_as_date_time :my_birth_date, :year_range => 1980..2005, :allow_nil => false
validates_as_date :her_birth_date, :allow_nil => false, :on => :create
validates_as_time :his_birth_date, :allow_nil => false, :on => :update
end
Tests:
Some tests have been added.
License:
See the LICENSE file.