validates_timeliness 5.0.0.beta2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.rdoc +16 -16
- data/lib/validates_timeliness/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a87264d54db8505c8dcbeff59eda9c7e091d07942c97de3f34e7f9fc2f465c8
|
4
|
+
data.tar.gz: 504d91a6c0af936ffd864180c4e174521598c13f4c7774966b86808138e6fc51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 335b52bbbd66dd0a2e0a5ca1db25637eb2afb9007418d5a035342de756f391325170ec62fce16f422d30f80ffdf0b2f12e7fdb3fbbcecfb82d3ebbed2e6e2b25
|
7
|
+
data.tar.gz: cc3000300065dac0b74164ce5491f541fd338fa7649a6a0da722ae4179de48a7c46ec1f6c47aee2a91769058e0e7e2a2565d1d0b1b3c29d8495f5a9814d94041
|
data/README.rdoc
CHANGED
@@ -49,21 +49,21 @@ NOTE: You may wish to enable the plugin parser and the extensions to start. Plea
|
|
49
49
|
|
50
50
|
validates_datetime :occurred_at
|
51
51
|
|
52
|
-
validates_date :date_of_birth, :
|
53
|
-
:
|
52
|
+
validates_date :date_of_birth, before: lambda { 18.years.ago },
|
53
|
+
before_message: "must be at least 18 years old"
|
54
54
|
|
55
|
-
validates_datetime :finish_time, :
|
55
|
+
validates_datetime :finish_time, after: :start_time # Method symbol
|
56
56
|
|
57
|
-
validates_date :booked_at, :
|
57
|
+
validates_date :booked_at, on: :create, on_or_after: :today # See Restriction Shorthand.
|
58
58
|
|
59
|
-
validates_time :booked_at, :
|
60
|
-
validates_time :booked_at, :
|
61
|
-
validates_time :booked_at, :
|
59
|
+
validates_time :booked_at, between: ['9:00am', '5:00pm'] # On or after 9:00AM and on or before 5:00PM
|
60
|
+
validates_time :booked_at, between: '9:00am'..'5:00pm' # The same as previous example
|
61
|
+
validates_time :booked_at, between: '9:00am'...'5:00pm' # On or after 9:00AM and strictly before 5:00PM
|
62
62
|
|
63
|
-
validates_time :breakfast_time, :
|
64
|
-
:
|
65
|
-
:
|
66
|
-
:
|
63
|
+
validates_time :breakfast_time, on_or_after: '6:00am',
|
64
|
+
on_or_after_message: 'must be after opening time',
|
65
|
+
before: :lunchtime,
|
66
|
+
before_message: 'must be before lunch time'
|
67
67
|
|
68
68
|
|
69
69
|
== Usage
|
@@ -72,14 +72,14 @@ To validate a model with a date, time or datetime attribute you just use the
|
|
72
72
|
validation method
|
73
73
|
|
74
74
|
class Person < ActiveRecord::Base
|
75
|
-
validates_date :date_of_birth, :
|
75
|
+
validates_date :date_of_birth, on_or_before: lambda { Date.current }
|
76
76
|
# or
|
77
|
-
validates :date_of_birth, :
|
77
|
+
validates :date_of_birth, timeliness: {on_or_before: lambda { Date.current }, type: :date}
|
78
78
|
end
|
79
79
|
|
80
80
|
or even on a specific record, per ActiveModel API.
|
81
81
|
|
82
|
-
@person.validates_date :date_of_birth, :
|
82
|
+
@person.validates_date :date_of_birth, on_or_before: lambda { Date.current }
|
83
83
|
|
84
84
|
|
85
85
|
The list of validation methods available are as follows:
|
@@ -206,14 +206,14 @@ plugin allows you to use shorthand symbols for often used relative times or date
|
|
206
206
|
|
207
207
|
Just provide the symbol as the option value like so:
|
208
208
|
|
209
|
-
validates_date :birth_date, :
|
209
|
+
validates_date :birth_date, on_or_before: :today
|
210
210
|
|
211
211
|
The :today symbol is evaluated as <tt>lambda { Date.today }</tt>. The :now and :today
|
212
212
|
symbols are pre-configured. Configure your own like so:
|
213
213
|
|
214
214
|
# in the setup block
|
215
215
|
config.restriction_shorthand_symbols.update(
|
216
|
-
:
|
216
|
+
yesterday: lambda { 1.day.ago }
|
217
217
|
)
|
218
218
|
|
219
219
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validates_timeliness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.0
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Meehan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: timeliness
|
@@ -99,9 +99,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
99
|
version: '0'
|
100
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- - "
|
102
|
+
- - ">="
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version:
|
104
|
+
version: '0'
|
105
105
|
requirements: []
|
106
106
|
rubygems_version: 3.0.3
|
107
107
|
signing_key:
|