mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-22 22:06:45 +00:00
a little more docs
This commit is contained in:
parent
710ed92721
commit
265a3b884a
53
README
53
README
@ -1,50 +1,63 @@
|
|||||||
= validates_timeliness
|
= validates_timeliness
|
||||||
|
|
||||||
* Source: http://github.com/adzap/validates_timeliness
|
* Source: http://github.com/adzap/validates_timeliness
|
||||||
* Tickets:
|
* Tickets: http://adzap.lighthouseapp.com/projects/14111-validates_timeliness
|
||||||
|
|
||||||
|
|
||||||
== DESCRIPTION
|
== DESCRIPTION
|
||||||
|
|
||||||
The time and date validation has always been a problem in Rails. To do it
|
Validate dates, times and datetimes for Rails 2.x. Plays nicely with new
|
||||||
properly you need to fiddle with the Rails internals a fair bit. Where once
|
features such as automatic timezone handling and dirty attributes. Allows
|
||||||
there may have been hope of including more support for this validation in Rails,
|
date/time atttributes to behave like other attribute types by allowing you to
|
||||||
since the release of Rails 2.1 those hopes were dashed as it has become an order
|
review the raw entered value before it is converted.
|
||||||
of magnitude harder due the excellent additions of the improved timezone handling
|
|
||||||
and dirty attributes.
|
|
||||||
|
|
||||||
This plugin allows the validation of dates and times in Rails 2.0.x and above.
|
|
||||||
|
|
||||||
|
|
||||||
== FEATURES/PROBLEMS
|
== FEATURES/PROBLEMS
|
||||||
|
|
||||||
* Adds ActiveRecord validation for dates and times
|
* Adds ActiveRecord validation for dates, times and datetimes
|
||||||
|
|
||||||
* Adds better traceability of dates and times entered with the use the
|
* Adds better transparency of date/time attributes restoring ability to view
|
||||||
before_type_cast for date and time columns to look at the original value
|
raw value before type casting, which was lost in Rails 2.1 to get the better
|
||||||
entered before type casting.
|
timezone features.
|
||||||
|
|
||||||
* Allows pluggable date and time parsing with other parsers of your choosing (eg Chronic)
|
* 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
|
== INSTALLATION
|
||||||
|
|
||||||
./script/plugin http://github.com/adzap/validates_timeliness
|
Rails 2.1
|
||||||
|
./script/plugin git://github.com/adzap/validates_timeliness
|
||||||
|
|
||||||
|
Rails 2.0
|
||||||
|
|
||||||
|
|
||||||
== USAGE
|
== USAGE
|
||||||
|
|
||||||
To validate a model with a date or datetime attribute you just use the validation
|
To validate a model with a date, time or datetime attribute you just use the
|
||||||
method
|
validation method
|
||||||
|
|
||||||
class Person < ActiveRecord::Base
|
class Person < ActiveRecord::Base
|
||||||
validates_timeliness_of :date_of_birth
|
validates_timeliness_of :date_of_birth
|
||||||
|
|
||||||
end
|
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 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 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 validation method has the usual options plus some specific ones to restrict
|
||||||
the valid range
|
the valid range
|
||||||
|
|
||||||
@ -57,3 +70,5 @@ the valid range
|
|||||||
- on_or_after
|
- on_or_after
|
||||||
- type
|
- type
|
||||||
|
|
||||||
|
|
||||||
|
MUCH MORE DOCS TO COME
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user