gbdev-validates_as_date_time 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/CHANGELOG +3 -0
  2. data/README +4 -2
  3. data/lib/validates_as_date_time.rb +12 -9
  4. metadata +2 -2
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ 0.5.2 - Sep 08th 2008
2
+ * Added :on => option (Specifies when this validation is active (default is :save, other options :create, :update)
3
+
1
4
  0.5.1 - Aug 15th 2008
2
5
  * Initial release
3
6
  * Gem'ified plugin
data/README CHANGED
@@ -1,8 +1,7 @@
1
1
  ValidatesAsDateTime
2
2
  ===================
3
3
  This Ruby on Rails gem/plugin implements an ActiveRecord validation helper called
4
- validates_as_date_time which validates U.S. dates, times, or date-times. It accepts
5
- strings, and ruby Date, Time, or DateTime objects.
4
+ validates_as_date_time which validates U.S. dates, times, or date-times.
6
5
 
7
6
  Installation:
8
7
  =============
@@ -20,6 +19,9 @@ In your model file do something like:
20
19
 
21
20
  class MyClass < ActiveRecord::Base
22
21
  validates_as_date_time :my_birth_date, :year_range => 1980..2005, :allow_nil => false
22
+ validates_as_date :her_birth_date, :allow_nil => false, :on => :create
23
+ validates_as_time :his_birth_date, :allow_nil => false, :on => :update
24
+
23
25
  end
24
26
 
25
27
  Tests:
@@ -30,7 +30,8 @@ module ActiveRecord
30
30
  configuration = {
31
31
  :message => 'is an invalid time',
32
32
  :with => /^#{regExpStr}$/,
33
- :allow_nil => false }
33
+ :allow_nil => false,
34
+ :on => :save }
34
35
 
35
36
  configuration.update(attr_names.pop) if attr_names.last.is_a?(Hash)
36
37
 
@@ -55,10 +56,11 @@ module ActiveRecord
55
56
  def validates_as_date(*attr_names)
56
57
  regExpStr = '(([0-1]?[0-9])\/[0-3]?[0-9]\/[0-9]{4})'
57
58
  configuration = {
58
- :message => 'is an invalid date',
59
- :with => /^#{regExpStr}$/,
60
- :allow_nil => false,
61
- :year_range => nil }
59
+ :message => 'is an invalid date',
60
+ :with => /^#{regExpStr}$/,
61
+ :allow_nil => false,
62
+ :year_range => nil,
63
+ :on => :save }
62
64
 
63
65
  configuration.update(attr_names.pop) if attr_names.last.is_a?(Hash)
64
66
 
@@ -85,10 +87,11 @@ module ActiveRecord
85
87
  def validates_as_date_time(*attr_names)
86
88
  regExpStr = '(([0-1]?[0-9])\/[0-3]?[0-9]\/[0-9]{4}) *([0-9]{1,2}(:[0-9]{2})? *(am|pm))?'
87
89
  configuration = {
88
- :message => 'is an invalid datetime',
89
- :with => /^#{regExpStr}$/,
90
- :allow_nil => false,
91
- :year_range => nil }
90
+ :message => 'is an invalid datetime',
91
+ :with => /^#{regExpStr}$/,
92
+ :allow_nil => false,
93
+ :year_range => nil,
94
+ :on => :save }
92
95
 
93
96
  configuration.update(attr_names.pop) if attr_names.last.is_a?(Hash)
94
97
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gbdev-validates_as_date_time
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wes Hays
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2008-08-15 00:00:00 -07:00
13
+ date: 2008-09-08 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16