validates_timeliness 6.0.0.beta2 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +4 -9
- data/CHANGELOG.md +337 -0
- data/README.md +148 -150
- data/gemfiles/rails_6_0.gemfile +0 -1
- data/gemfiles/rails_edge.gemfile +0 -1
- data/lib/validates_timeliness/version.rb +1 -1
- data/spec/spec_helper.rb +2 -1
- data/spec/validates_timeliness/converter_spec.rb +5 -5
- data/spec/validates_timeliness/extensions/date_time_select_spec.rb +6 -2
- data/spec/validates_timeliness/validator/is_at_spec.rb +5 -1
- data/spec/validates_timeliness/validator_spec.rb +5 -1
- data/validates_timeliness.gemspec +12 -2
- metadata +13 -9
- data/CHANGELOG.rdoc +0 -222
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1b8043b997be8d2c2c20462ad6ff2569c36f361e831648e62afcdccfb34a9a9
|
4
|
+
data.tar.gz: 4fd9cdea497d79b06469b973669f961aca84fb876c0fdbc00b66d5eb0006f62d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 103153fbfef87bbf3dabb2ec3bf1fe8c9178ad45dfda1d90948ca21802c40a7a70c41089e85bb717ed5f9861c163ce67058d9016c6e68e0aaa1bac4684e96971
|
7
|
+
data.tar.gz: de9ba7e8bb62fe6ccffb5e9e2507ec11fcbf8b30403ebf1c1d0e91ac25d1aa5377f2147d5b508ef0a2ce23ad71ce3ce440ce3282c011abeb7f1a47b3f63b9b17
|
data/.github/workflows/ci.yml
CHANGED
@@ -21,7 +21,8 @@ jobs:
|
|
21
21
|
ruby: 3.0
|
22
22
|
|
23
23
|
name: ${{ matrix.gemfile }}, ruby ${{ matrix.ruby }}
|
24
|
-
|
24
|
+
env:
|
25
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
|
25
26
|
steps:
|
26
27
|
- uses: actions/checkout@v2
|
27
28
|
|
@@ -29,13 +30,7 @@ jobs:
|
|
29
30
|
uses: ruby/setup-ruby@v1
|
30
31
|
with:
|
31
32
|
ruby-version: ${{ matrix.ruby }}
|
32
|
-
bundler-cache:
|
33
|
-
|
34
|
-
- name: Bundle install
|
35
|
-
run: |
|
36
|
-
bundle config set gemfile "${GITHUB_WORKSPACE}/gemfiles/${{ matrix.gemfile }}.gemfile"
|
37
|
-
bundle install --jobs 4 --retry 3
|
33
|
+
bundler-cache: true
|
38
34
|
|
39
35
|
- name: Run specs
|
40
|
-
run:
|
41
|
-
bundle exec rspec
|
36
|
+
run: bundle exec rspec
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,337 @@
|
|
1
|
+
# 5.0.0 [2021-04-03]
|
2
|
+
* Fix DateTimeSelect extension support (AquisTech)
|
3
|
+
* Relaxed Timeliness dependency version which allows for >= 0.4.0 with
|
4
|
+
threadsafety fix for use_us_formats and use_euro_formats for hot switching
|
5
|
+
|
6
|
+
in a request.
|
7
|
+
* Add initializer to ensure Timeliness v0.4+ ambiguous date config is set
|
8
|
+
correctly when using `use_euro_formats` or `remove_use_formats'.
|
9
|
+
* Add Ruby 3 compatibility
|
10
|
+
* Add Rails 6.1 compatibility
|
11
|
+
|
12
|
+
|
13
|
+
Breaking Changes
|
14
|
+
* Update Multiparameter extension to use ActiveRecord type classes with
|
15
|
+
multiparameter handling which stores a hash of multiparamter values as the
|
16
|
+
value before type cast, no longer a mushed datetime string
|
17
|
+
* Removed all custom plugin attribute methods and method overrides in favour
|
18
|
+
using ActiveModel type system
|
19
|
+
|
20
|
+
|
21
|
+
# 4.1.0 [2019-06-11]
|
22
|
+
* Relaxed Timeliness dependency version to >= 0.3.10 and < 1, which allows
|
23
|
+
version 0.4 with threadsafety fix for use_us_formats and use_euro_formats
|
24
|
+
hot switching in a request.
|
25
|
+
|
26
|
+
|
27
|
+
# 4.0.2 [2016-01-07]
|
28
|
+
* Fix undefine_generated_methods ivar guard setting to false
|
29
|
+
|
30
|
+
|
31
|
+
# 4.0.1 [2016-01-06]
|
32
|
+
* Fix undefine_generated_methods thread locking bug
|
33
|
+
* Created an ActiveModel ORM, for manual require if using without any full
|
34
|
+
blown ORM
|
35
|
+
|
36
|
+
|
37
|
+
# 4.0.0 [2015-12-29]
|
38
|
+
* Extracted mongoid support into
|
39
|
+
https://github.com/adzap/validates_timeliness-mongoid which is broken (not
|
40
|
+
supported anymore).
|
41
|
+
* Fixed Rails 4.0, 4.1 and 4.2 compatability issues
|
42
|
+
* Upgrade specs to RSpec 3
|
43
|
+
* Added travis config
|
44
|
+
* Huge thanks to @johncarney for keeping it alive with his fork
|
45
|
+
(https://github.com/johncarney/validates_timeliness)
|
46
|
+
|
47
|
+
|
48
|
+
# 3.0.15 [2015-12-29]
|
49
|
+
* Fixes mongoid 3 support and removes mongoid 2 support(johnnyshields)
|
50
|
+
* Some documentation/comments tidying
|
51
|
+
* Some general tidying up
|
52
|
+
|
53
|
+
|
54
|
+
# 3.0.14 [2012-08-23]
|
55
|
+
* Fix for using validates :timeliness => {} form to correctly add attributes
|
56
|
+
to timeliness validated attributes.
|
57
|
+
|
58
|
+
|
59
|
+
# 3.0.13 [2012-08-21]
|
60
|
+
* Fix ActiveRecord issues with using plugin parser by using old way of
|
61
|
+
caching values.
|
62
|
+
* Allow any ActiveRecord non-column attribute to be validated
|
63
|
+
|
64
|
+
|
65
|
+
# 3.0.12 [2012-06-23]
|
66
|
+
* Fix load order issue when relying on Railtie to load ActiveRecord
|
67
|
+
extension
|
68
|
+
|
69
|
+
|
70
|
+
# 3.0.11 [2012-04-01]
|
71
|
+
* Change dependency on Timeliness version due to a broken release
|
72
|
+
|
73
|
+
|
74
|
+
# 3.0.10 [2012-03-26]
|
75
|
+
* Fix for ActiveRecord shim and validation with :allow_blank => true in AR
|
76
|
+
3.1+. Fixes issue#52.
|
77
|
+
|
78
|
+
|
79
|
+
# 3.0.9 [2012-03-26]
|
80
|
+
* ActiveRecord 3.1+ suport
|
81
|
+
* Fixes for multiparameter extension with empty date values (thanks @mogox,
|
82
|
+
@Sharagoz)
|
83
|
+
|
84
|
+
|
85
|
+
# 3.0.8 [2011-12-24]
|
86
|
+
* Remove deprecated InstanceMethods module when using AS::Concern
|
87
|
+
(carlosantoniodasilva)
|
88
|
+
* Update Mongoid shim for v2.3 compatability.
|
89
|
+
|
90
|
+
|
91
|
+
# 3.0.7 [2011-09-21]
|
92
|
+
* Fix ActiveRecord before_type_cast extension for non-dirty attributes.
|
93
|
+
* Don't override AR before_type_cast for >= 3.1.0 which now has it's own
|
94
|
+
implementation for date/time attributes.
|
95
|
+
* Fix DateTimeSelect extension to convert params to integers (#45)
|
96
|
+
* Add #change method to DateTimeSelect extension (@trusche, #45)
|
97
|
+
* Cleanup Mongoid shim.
|
98
|
+
|
99
|
+
|
100
|
+
# 3.0.6 [2011-05-09]
|
101
|
+
* Fix for AR type conversion for date columns when using plugin parser.
|
102
|
+
* Add timeliness_type_cast_code for ORM specific type casting after parsing.
|
103
|
+
|
104
|
+
|
105
|
+
# 3.0.5 [2011-01-29]
|
106
|
+
* Fix for Conversion#parse when given nil value (closes issue #34)
|
107
|
+
|
108
|
+
|
109
|
+
# 3.0.4 [2011-01-22]
|
110
|
+
* Fix :between option which was being ignored (ebeigarts)
|
111
|
+
* Use class_attribute to remove deprecated class_inheritable_accessor
|
112
|
+
* Namespace copied validator class to ActiveModel::Validations::Timeliness
|
113
|
+
for :timeliness option
|
114
|
+
|
115
|
+
|
116
|
+
# 3.0.3 [2010-12-11]
|
117
|
+
* Fix validation of values which don't respond to to_date or to_time
|
118
|
+
(renatoelias)
|
119
|
+
|
120
|
+
|
121
|
+
# 3.0.2 [2010-12-04]
|
122
|
+
* Fix AR multiparameter extension for Date columns
|
123
|
+
* Update to Timeliness 0.3.2 for zone abbreviation and offset support
|
124
|
+
|
125
|
+
|
126
|
+
# 3.0.1 [2010-11-02]
|
127
|
+
* Generate timeliness write methods in an included module to allow
|
128
|
+
overriding in model class (josevalim)
|
129
|
+
|
130
|
+
|
131
|
+
# 3.0.0 [2010-10-18]
|
132
|
+
* Rails 3 and ActiveModel compatibility
|
133
|
+
* Uses ActiveModel::EachValidator as validator base class.
|
134
|
+
* Configuration settings stored in ValidatesTimeliness module only.
|
135
|
+
ValidatesTimeliness.setup block to configure.
|
136
|
+
* Parser extracted to the Timeliness gem http://github.com/adzap/timeliness
|
137
|
+
* Parser is disabled by default. See initializer for enabling it.
|
138
|
+
* Removed RSpec matcher. Encouraged poor specs by copy-pasting from spec to
|
139
|
+
model, or worse, the other way round.
|
140
|
+
* Method override for parsing and before type cast values is on validated
|
141
|
+
attributes only. Old version handled all date/datetime columns, validates
|
142
|
+
or not. Too intrusive.
|
143
|
+
* Add validation helpers to classes using extend_orms config setting. e.g.
|
144
|
+
conf.extend_orms = [ :active_record ]
|
145
|
+
* Changed :between option so it is split into :on_or_after and :on_or_before
|
146
|
+
option values. The error message for either failing check will be used
|
147
|
+
instead of a between error message.
|
148
|
+
* Provides :timeliness option key for validates class method. Be sure to
|
149
|
+
pass :type option as well e.g. :type => :date.
|
150
|
+
* Allows validation methods to be called on record instances as per
|
151
|
+
ActiveModel API.
|
152
|
+
* Performs parsing (optional) and raw value caching (before_type_cast) on
|
153
|
+
validated attributes only. It used to be all date, time and datetime
|
154
|
+
attributes.
|
155
|
+
|
156
|
+
|
157
|
+
# 2.3.1 [2010-03-19]
|
158
|
+
* Fixed bug where custom attribute writer method for date/times were being
|
159
|
+
overriden
|
160
|
+
|
161
|
+
|
162
|
+
# 2.3.0 [2010-02-04]
|
163
|
+
* Backwards incompatible change to :equal_to option. Fixed error message
|
164
|
+
clash with :equal_to option which exists in Rails already. Option is now
|
165
|
+
:is_at.
|
166
|
+
* Fixed I18n support so it returns missing translation message instead of
|
167
|
+
error
|
168
|
+
* Fixed attribute method bug. Write method was bypassed when method was
|
169
|
+
first generated and used Rails default parser.
|
170
|
+
* Fixed date/time selects when using enable_datetime_select_extension! when
|
171
|
+
some values empty
|
172
|
+
* Fixed ISO8601 datetime format which is now split into two formats
|
173
|
+
* Changed I18n error value format to fallback to global default if missing
|
174
|
+
in locale
|
175
|
+
* Refactored date/time select invalid value extension to use param values.
|
176
|
+
Functionality will be extracted from plugin for v3.
|
177
|
+
|
178
|
+
|
179
|
+
# 2.2.2 [2009-09-19]
|
180
|
+
* Fixed dummy_time using make_time to respect timezone. Fixes 1.9.1 bug.
|
181
|
+
|
182
|
+
|
183
|
+
# 2.2.1 [2009-09-12]
|
184
|
+
* Fixed dummy date part for time types in Validator.type_cast_value
|
185
|
+
* No more core extensions! Removed dummy_time methods.
|
186
|
+
|
187
|
+
|
188
|
+
# 2.2.0 [2009-09-12]
|
189
|
+
* Ruby 1.9 support!
|
190
|
+
* Customise dummy date values for time types. See DUMMY DATE FOR TIME TYPES.
|
191
|
+
* Fixed matcher conflict with Shoulda. Load plugin matcher manually now see
|
192
|
+
matcher section in README
|
193
|
+
* Fixed :ignore_usec when used with :with_time or :with_date
|
194
|
+
* Some clean up and refactoring
|
195
|
+
|
196
|
+
|
197
|
+
# 2.1.0 [2009-06-20]
|
198
|
+
* Added ambiguous year threshold setting in Formats class to customize the
|
199
|
+
threshold for 2 digit years (See README)
|
200
|
+
* Fixed interpolation values in custom error message for Rails 2.2+
|
201
|
+
* Fixed custom I18n local override of en locale
|
202
|
+
* Dramatically simplified ActiveRecord monkey patching and hackery
|
203
|
+
|
204
|
+
|
205
|
+
# 2.0.0 [2009-04-12]
|
206
|
+
* Error value formats are now specified in the i18n locale file instead of
|
207
|
+
updating plugin hash. See OTHER CUSTOMISATION section in README.
|
208
|
+
* Date/time select helper extension is disabled by default. To enable see
|
209
|
+
DISPLAY INVALID VALUES IN DATE HELPERS section in README to enable.
|
210
|
+
* Added :format option to limit validation to a single format if desired
|
211
|
+
* Matcher now supports :equal_to option
|
212
|
+
* Formats.parse can take :include_offset option to include offset value from
|
213
|
+
string in seconds, if string contains an offset. Offset not used in rest
|
214
|
+
of plugin yet.
|
215
|
+
* Refactored to remove as much plugin code from ActiveRecord as possible.
|
216
|
+
|
217
|
+
|
218
|
+
# 1.1.7 [2009-03-26]
|
219
|
+
* Minor change to multiparameter attributes which I had not properly
|
220
|
+
implemented for chaining
|
221
|
+
|
222
|
+
|
223
|
+
# 1.1.6 [2009-03-19]
|
224
|
+
* Rail 2.3 support
|
225
|
+
* Added :with_date and :with_time options. They allow an attribute to be
|
226
|
+
combined with another attribute or value to make a datetime value for
|
227
|
+
validation against the temporal restrictions
|
228
|
+
* Added :equal_to option
|
229
|
+
* Option key validation
|
230
|
+
* Better behaviour with other plugins using alias_method_chain on
|
231
|
+
read_attribute and define_attribute_methods
|
232
|
+
* Added option to enable datetime_select extension for future use to
|
233
|
+
optionally enable. Enabled by default until version 2.
|
234
|
+
* Added :ignore_usec option for datetime restrictions to be compared without
|
235
|
+
microsecond
|
236
|
+
* some refactoring
|
237
|
+
|
238
|
+
|
239
|
+
# 1.1.5 [2009-01-21]
|
240
|
+
* Fixed regex for 'yy' format token which wasn't greedy enough for date
|
241
|
+
formats ending with year when a datetime string parsed as date with a 4
|
242
|
+
digit year
|
243
|
+
|
244
|
+
|
245
|
+
# 1.1.4 [2009-01-13]
|
246
|
+
* Make months names respect i18n in Formats
|
247
|
+
|
248
|
+
|
249
|
+
# 1.1.3 [2009-01-13]
|
250
|
+
* Fixed bug where time and date attributes still being parsed on read using
|
251
|
+
Rails default parser [reported by Brad (pvjq)]
|
252
|
+
|
253
|
+
|
254
|
+
# 1.1.2 [2009-01-12]
|
255
|
+
* Fixed bugs
|
256
|
+
* matcher failing for custom error message without interpolation keys
|
257
|
+
using I18n
|
258
|
+
* validator custom error messages not being extracted
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
# 1.1.1 [2009-01-03]
|
263
|
+
* Fixed bug in matcher for options local variable
|
264
|
+
|
265
|
+
|
266
|
+
# 1.1.0 [2009-01-01]
|
267
|
+
* Added between option
|
268
|
+
|
269
|
+
|
270
|
+
# 1.0.0 [2008-12-06]
|
271
|
+
* Gemified!
|
272
|
+
* Refactor of plugin into a Data Mapper style validator class which makes
|
273
|
+
for a cleaner implementation and possible future MerbData Mapper support
|
274
|
+
* Added Rails 2.2 i18n support. Plugin error messages can specified in
|
275
|
+
locale files. See README.
|
276
|
+
* ignore_datetime_restriction_errors setting has been moved from AR to
|
277
|
+
ValidatesTimeliness::Validator.ignore_restriction_errors
|
278
|
+
* date_time_error_value_formats setting has been moved from AR to
|
279
|
+
ValidatesTimeliness::Validator.error_value_formats
|
280
|
+
* Namespaced modules and specs
|
281
|
+
* Clean up of specs
|
282
|
+
* fixed a few bugs
|
283
|
+
* accessor methods not generating properly due method name stored as
|
284
|
+
symbol in generated_attributes which fails on lookup
|
285
|
+
* force value assigned to time/datetime attributes to time objects
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
# 0.1.0 [2008-12-06]
|
290
|
+
* Tagged plugin as version 0.1.0
|
291
|
+
|
292
|
+
|
293
|
+
# 2008-11-13
|
294
|
+
* allow uppercase meridian to be valid [reported by Alex
|
295
|
+
(http://alex.digns.com/)]
|
296
|
+
|
297
|
+
|
298
|
+
# 2008-10-28
|
299
|
+
* fixed bug when dirty attributes not reflecting change when attribute
|
300
|
+
changed from time value to nil [reported by Brad (pvjq)]
|
301
|
+
* fixes for Rails 2.2 compatibility. Will refactor in to Rails version
|
302
|
+
specific branches in the future.
|
303
|
+
|
304
|
+
|
305
|
+
# 2008-09-24
|
306
|
+
* refactored attribute write method definitions
|
307
|
+
|
308
|
+
|
309
|
+
# 2008-08-25
|
310
|
+
* fixed bug for non-timezone write method not updating changed attributes
|
311
|
+
hash [reported by Sylvestre Mergulhão]
|
312
|
+
|
313
|
+
|
314
|
+
# 2008-08-22
|
315
|
+
* fixed bug with attribute cache not clearing on write for date and time
|
316
|
+
columns [reported by Sylvestre Mergulhão]
|
317
|
+
* parse method returns Date object for date column assigned string as per
|
318
|
+
normal Rails behaviour
|
319
|
+
* parse method returns same object type when assigned Date or Time object as
|
320
|
+
per normal Rails behaviour
|
321
|
+
|
322
|
+
|
323
|
+
# 2008-08-07
|
324
|
+
* modified matcher option value parsing to allow same value types as
|
325
|
+
validation method
|
326
|
+
* fixed matcher message
|
327
|
+
|
328
|
+
|
329
|
+
# 2008-08-02
|
330
|
+
* refactored validation
|
331
|
+
* refactored matcher
|
332
|
+
|
333
|
+
|
334
|
+
# 2008-07-30
|
335
|
+
* removed setting values to nil when validation fails to preserve
|
336
|
+
before_type_cast value
|
337
|
+
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# ValidatesTimeliness [![build](https://github.com/adzap/validates_timeliness/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/adzap/validates_timeliness/actions/workflows/ci.yml)
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
- Source: https://github.com/adzap/validates_timeliness
|
4
|
+
- Issues: https://github.com/adzap/validates_timeliness/issues
|
5
5
|
|
6
6
|
|
7
7
|
## Description
|
@@ -11,120 +11,116 @@ ActiveModel.
|
|
11
11
|
|
12
12
|
Old Rails versions:
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
* Rails 5.x: [https://github.com/adzap/validates_timeliness/tree/5-0-stable]
|
14
|
+
- Rails 4.x: [https://github.com/adzap/validates_timeliness/tree/4-0-stable]
|
15
|
+
- Rails 5.x: [https://github.com/adzap/validates_timeliness/tree/5-0-stable]
|
17
16
|
|
18
17
|
|
19
18
|
## Features
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
* Uses extensible date/time parser (Using [timeliness
|
29
|
-
gem](https://github.com/adzap/timeliness). See Plugin Parser)
|
30
|
-
|
31
|
-
* Adds extensions to fix Rails date/time select issues (See Extensions)
|
32
|
-
|
33
|
-
* Supports I18n for the error messages. For multi-language support try
|
34
|
-
[timeliness-i18n gem](https://github.com/pedrofurtado/timeliness-i18n).
|
35
|
-
|
36
|
-
* Supports all the Rubies (that any sane person would be using in
|
37
|
-
production).
|
20
|
+
- Adds validation for dates, times and datetimes to ActiveModel
|
21
|
+
- Handles timezones and type casting of values for you
|
22
|
+
- Only Rails date/time validation plugin offering complete validation (See ORM/ODM support)
|
23
|
+
- Uses extensible date/time parser (Using [timeliness gem](https://github.com/adzap/timeliness). See Plugin Parser)
|
24
|
+
- Adds extensions to fix Rails date/time select issues (See Extensions)
|
25
|
+
- Supports I18n for the error messages. For multi-language support try [timeliness-i18n gem](https://github.com/pedrofurtado/timeliness-i18n).
|
26
|
+
- Supports all the Rubies (that any sane person would be using in production).
|
38
27
|
|
39
28
|
|
40
29
|
## Installation
|
41
30
|
|
42
|
-
|
43
|
-
|
31
|
+
In Gemfile
|
32
|
+
```ruby
|
33
|
+
gem 'validates_timeliness', '~> 6.0.0'
|
34
|
+
```
|
44
35
|
|
45
|
-
|
46
|
-
|
36
|
+
Run bundler:
|
37
|
+
```bash
|
38
|
+
$ bundle install
|
39
|
+
```
|
47
40
|
|
48
41
|
Then run
|
42
|
+
```bash
|
43
|
+
$ rails generate validates_timeliness:install
|
44
|
+
```
|
49
45
|
|
50
|
-
|
46
|
+
This creates configuration initializer and locale files. In the initializer, there are a number of config options to customize the plugin.
|
51
47
|
|
52
|
-
|
53
|
-
there are a number of config options to customize the plugin.
|
54
|
-
|
55
|
-
NOTE: You may wish to enable the plugin parser and the extensions to start.
|
48
|
+
**NOTE**: You may wish to enable the plugin parser and the extensions to start.
|
56
49
|
Please read those sections first.
|
57
50
|
|
58
51
|
## Examples
|
59
52
|
|
60
|
-
|
53
|
+
```ruby
|
54
|
+
validates_datetime :occurred_at
|
61
55
|
|
62
|
-
|
63
|
-
|
56
|
+
validates_date :date_of_birth, before: lambda { 18.years.ago },
|
57
|
+
before_message: "must be at least 18 years old"
|
64
58
|
|
65
|
-
|
59
|
+
validates_datetime :finish_time, after: :start_time # Method symbol
|
66
60
|
|
67
|
-
|
61
|
+
validates_date :booked_at, on: :create, on_or_after: :today # See Restriction Shorthand.
|
68
62
|
|
69
|
-
|
70
|
-
|
71
|
-
|
63
|
+
validates_time :booked_at, between: ['9:00am', '5:00pm'] # On or after 9:00AM and on or before 5:00PM
|
64
|
+
validates_time :booked_at, between: '9:00am'..'5:00pm' # The same as previous example
|
65
|
+
validates_time :booked_at, between: '9:00am'...'5:00pm' # On or after 9:00AM and strictly before 5:00PM
|
72
66
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
67
|
+
validates_time :breakfast_time, on_or_after: '6:00am',
|
68
|
+
on_or_after_message: 'must be after opening time',
|
69
|
+
before: :lunchtime,
|
70
|
+
before_message: 'must be before lunch time'
|
71
|
+
```
|
77
72
|
|
78
73
|
## Usage
|
79
74
|
|
80
75
|
To validate a model with a date, time or datetime attribute you just use the
|
81
|
-
validation method
|
76
|
+
validation method:
|
82
77
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
78
|
+
```ruby
|
79
|
+
class Person < ActiveRecord::Base
|
80
|
+
validates_date :date_of_birth, on_or_before: lambda { Date.current }
|
81
|
+
# or
|
82
|
+
validates :date_of_birth, timeliness: { on_or_before: lambda { Date.current }, type: :date }
|
83
|
+
end
|
84
|
+
```
|
88
85
|
|
89
86
|
or even on a specific record, per ActiveModel API.
|
90
|
-
|
91
|
-
|
87
|
+
```ruby
|
88
|
+
@person.validates_date :date_of_birth, on_or_before: lambda { Date.current }
|
89
|
+
```
|
92
90
|
|
93
91
|
The list of validation methods available are as follows:
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
92
|
+
- `validates_date` - validate value as date
|
93
|
+
- `validates_time` - validate value as time only i.e. '12:20pm'
|
94
|
+
- `validates_datetime` - validate value as a full date and time
|
95
|
+
- `validates` - use the :timeliness key and set the type in the hash.
|
98
96
|
|
99
97
|
The validation methods take the usual options plus some specific ones to
|
100
98
|
restrict the valid range of dates or times allowed
|
101
99
|
|
102
100
|
Temporal options (or restrictions):
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
101
|
+
- `:is_at` - Attribute must be equal to value to be valid
|
102
|
+
- `:before` - Attribute must be before this value to be valid
|
103
|
+
- `:on_or_before` - Attribute must be equal to or before this value to be valid
|
104
|
+
- `:after` - Attribute must be after this value to be valid
|
105
|
+
- `:on_or_after` - Attribute must be equal to or after this value to be valid
|
106
|
+
- `:between` - Attribute must be between the values to be valid. Range or Array of 2 values.
|
109
107
|
|
110
108
|
Regular validation options:
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
109
|
+
- `:allow_nil` - Allow a nil value to be valid
|
110
|
+
- `:allow_blank` - Allows a nil or empty string value to be valid
|
111
|
+
- `:if` - Execute validation when :if evaluates true
|
112
|
+
- `:unless` - Execute validation when :unless evaluates false
|
113
|
+
- `:on` - Specify validation context e.g :save, :create or :update. Default is :save.
|
116
114
|
|
117
115
|
Special options:
|
118
|
-
|
119
|
-
|
116
|
+
- `:ignore_usec` - Ignores microsecond value on datetime restrictions
|
117
|
+
- `:format` - Limit validation to a single format for special cases. Requires plugin parser.
|
120
118
|
|
121
119
|
The temporal restrictions can take 4 different value types:
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
* A symbol matching a method name in the model
|
127
|
-
* String value
|
120
|
+
- Date, Time, or DateTime object value
|
121
|
+
- Proc or lambda object which may take an optional parameter, being the record object
|
122
|
+
- A symbol matching a method name in the model
|
123
|
+
- String value
|
128
124
|
|
129
125
|
|
130
126
|
When an attribute value is compared to temporal restrictions, they are
|
@@ -146,17 +142,15 @@ that the attribute is not just nil.
|
|
146
142
|
|
147
143
|
Each ORM/ODM requires a specific shim to fix it. The plugin includes a shim
|
148
144
|
for ActiveRecord and Mongoid. You can activate them like so
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
end
|
145
|
+
```ruby
|
146
|
+
ValidatesTimeliness.setup do |config|
|
147
|
+
# Extend ORM/ODMs for full support (:active_record).
|
148
|
+
config.extend_orms = [ :active_record ]
|
149
|
+
end
|
150
|
+
```
|
156
151
|
|
157
152
|
By default the plugin extends ActiveRecord if loaded. If you wish to extend
|
158
|
-
another ORM then look at the [wiki
|
159
|
-
page](https://github.com/adzap/validates_timeliness/wiki/ORM-Support) for more
|
153
|
+
another ORM then look at the [wiki page](https://github.com/adzap/validates_timeliness/wiki/ORM-Support) for more
|
160
154
|
information.
|
161
155
|
|
162
156
|
It is not required that you use a shim, but you will not catch errors when the
|
@@ -165,52 +159,54 @@ attribute value is invalid and evaluated to nil.
|
|
165
159
|
### Error Messages
|
166
160
|
|
167
161
|
Using the I18n system to define new defaults:
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
will be inserted.
|
162
|
+
```yml
|
163
|
+
en:
|
164
|
+
errors:
|
165
|
+
messages:
|
166
|
+
invalid_date: "is not a valid date"
|
167
|
+
invalid_time: "is not a valid time"
|
168
|
+
invalid_datetime: "is not a valid datetime"
|
169
|
+
is_at: "must be at %{restriction}"
|
170
|
+
before: "must be before %{restriction}"
|
171
|
+
on_or_before: "must be on or before %{restriction}"
|
172
|
+
after: "must be after %{restriction}"
|
173
|
+
on_or_after: "must be on or after %{restriction}"
|
174
|
+
```
|
175
|
+
|
176
|
+
The `%{restriction}` signifies where the interpolation value for the restriction will be inserted.
|
183
177
|
|
184
178
|
You can also use validation options for custom error messages. The following
|
185
179
|
option keys are available:
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
180
|
+
```ruby
|
181
|
+
:invalid_date_message
|
182
|
+
:invalid_time_message
|
183
|
+
:invalid_datetime_message
|
184
|
+
:is_at_message
|
185
|
+
:before_message
|
186
|
+
:on_or_before_message
|
187
|
+
:after_message
|
188
|
+
:on_or_after_message
|
189
|
+
```
|
190
|
+
|
191
|
+
**Note**: There is no `:between_message` option. The between error message should be
|
192
|
+
defined using the `:on_or_after` and `:on_or_before` (`:before` in case when
|
193
|
+
`:between` argument is a `Range` with excluded high value, see Examples) messages.
|
194
|
+
|
195
|
+
It is highly recommended you use the `I18n` system for error messages.
|
201
196
|
|
202
197
|
### Plugin Parser
|
203
198
|
|
204
199
|
The plugin uses the [timeliness gem](https://github.com/adzap/timeliness) as a
|
205
200
|
fast, configurable and extensible date and time parser. You can add or remove
|
206
|
-
valid formats for dates
|
201
|
+
valid formats for `dates`, `times`, and `datetimes`. It is also more strict than the
|
207
202
|
Ruby parser, which means it won't accept day of the month if it's not a valid
|
208
203
|
number for the month.
|
209
204
|
|
210
205
|
By default the parser is disabled. To enable it:
|
211
|
-
|
212
|
-
|
213
|
-
|
206
|
+
```ruby
|
207
|
+
# in the setup block
|
208
|
+
config.use_plugin_parser = true
|
209
|
+
```
|
214
210
|
|
215
211
|
Enabling the parser will mean that strings assigned to attributes validated
|
216
212
|
with the plugin will be parsed using the gem. See the
|
@@ -226,16 +222,16 @@ validations for something so common. To combat this the plugin allows you to
|
|
226
222
|
use shorthand symbols for often used relative times or dates.
|
227
223
|
|
228
224
|
Just provide the symbol as the option value like so:
|
225
|
+
```ruby
|
226
|
+
validates_date :birth_date, on_or_before: :today
|
227
|
+
```
|
229
228
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
config.restriction_shorthand_symbols.update(
|
237
|
-
yesterday: lambda { 1.day.ago }
|
238
|
-
)
|
229
|
+
The `:today` symbol is evaluated as `lambda { Date.current }`. The `:now` and
|
230
|
+
`:today` symbols are pre-configured. Configure your own like so:
|
231
|
+
```ruby
|
232
|
+
# in the setup block
|
233
|
+
config.restriction_shorthand_symbols.update(yesterday: lambda { 1.day.ago })
|
234
|
+
```
|
239
235
|
|
240
236
|
### Default Timezone
|
241
237
|
|
@@ -243,11 +239,12 @@ The plugin needs to know the default timezone you are using when parsing or
|
|
243
239
|
type casting values. If you are using ActiveRecord then the default is
|
244
240
|
automatically set to the same default zone as ActiveRecord. If you are using
|
245
241
|
another ORM you may need to change this setting.
|
242
|
+
```ruby
|
243
|
+
# in the setup block
|
244
|
+
config.default_timezone = :utc
|
245
|
+
```
|
246
246
|
|
247
|
-
|
248
|
-
config.default_timezone = :utc
|
249
|
-
|
250
|
-
By default it will be UTC if ActiveRecord is not loaded.
|
247
|
+
By default it will be `UTC` if ActiveRecord is not loaded.
|
251
248
|
|
252
249
|
### Dummy Date For Time Types
|
253
250
|
|
@@ -255,13 +252,13 @@ Given that Ruby has no support for a time-only type, all time type columns are
|
|
255
252
|
evaluated as a regular Time class objects with a dummy date value set. Rails
|
256
253
|
defines the dummy date as 2000-01-01. So a time of '12:30' is evaluated as a
|
257
254
|
Time value of '2000-01-01 12:30'. If you need to customize this for some
|
258
|
-
reason you can do so as follows
|
259
|
-
|
260
|
-
|
261
|
-
|
255
|
+
reason you can do so as follows:
|
256
|
+
```ruby
|
257
|
+
# in the setup block
|
258
|
+
config.dummy_date_for_time_type = [2009, 1, 1]
|
259
|
+
```
|
262
260
|
|
263
|
-
The value should be an array of 3 values being year, month and day in that
|
264
|
-
order.
|
261
|
+
The value should be an array of 3 values being year, month and day in that order.
|
265
262
|
|
266
263
|
### Temporal Restriction Errors
|
267
264
|
|
@@ -273,9 +270,10 @@ want to skip the option if no valid value was returned. By default these
|
|
273
270
|
errors are displayed in Rails test mode.
|
274
271
|
|
275
272
|
To turn them on/off:
|
276
|
-
|
277
|
-
|
278
|
-
|
273
|
+
```ruby
|
274
|
+
# in the setup block
|
275
|
+
config.ignore_restriction_errors = true
|
276
|
+
```
|
279
277
|
|
280
278
|
## Extensions
|
281
279
|
|
@@ -288,9 +286,10 @@ treated as valid. To handle these cases in a strict way, you can enable the
|
|
288
286
|
plugin extension to treat them as invalid dates.
|
289
287
|
|
290
288
|
To activate it, uncomment this line in the initializer:
|
291
|
-
|
292
|
-
|
293
|
-
|
289
|
+
```ruby
|
290
|
+
# in the setup block
|
291
|
+
config.enable_multiparameter_extension!
|
292
|
+
```
|
294
293
|
|
295
294
|
### Display Invalid Values in Select Helpers
|
296
295
|
|
@@ -301,21 +300,20 @@ pretty rare occurrence, given the select dropdowns for each date/time
|
|
301
300
|
component, but it may be something of interest.
|
302
301
|
|
303
302
|
To activate it, uncomment this line in the initializer:
|
304
|
-
|
305
|
-
|
306
|
-
|
303
|
+
```ruby
|
304
|
+
# in the setup block
|
305
|
+
config.enable_date_time_select_extension!
|
306
|
+
```
|
307
307
|
|
308
308
|
## Contributors
|
309
309
|
|
310
310
|
To see the generous people who have contributed code, take a look at the
|
311
|
-
[contributors
|
312
|
-
list](https://github.com/adzap/validates_timeliness/contributors).
|
311
|
+
[contributors list](https://github.com/adzap/validates_timeliness/contributors).
|
313
312
|
|
314
313
|
## Maintainers
|
315
314
|
|
316
|
-
*
|
317
|
-
|
315
|
+
* [Adam Meehan](https://github.com/adzap)
|
318
316
|
|
319
317
|
## License
|
320
318
|
|
321
|
-
Copyright (c)
|
319
|
+
Copyright (c) 2021 Adam Meehan, released under the MIT license.
|
data/gemfiles/rails_6_0.gemfile
CHANGED
data/gemfiles/rails_edge.gemfile
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -5,7 +5,7 @@ require 'active_model'
|
|
5
5
|
require 'active_model/validations'
|
6
6
|
require 'active_record'
|
7
7
|
require 'action_view'
|
8
|
-
require '
|
8
|
+
require 'active_support/testing/time_helpers'
|
9
9
|
|
10
10
|
require 'validates_timeliness'
|
11
11
|
require 'validates_timeliness/orm/active_model'
|
@@ -89,6 +89,7 @@ RSpec.configure do |c|
|
|
89
89
|
c.include(TagMatcher)
|
90
90
|
c.include(ModelHelpers)
|
91
91
|
c.include(ConfigHelper)
|
92
|
+
c.include(ActiveSupport::Testing::TimeHelpers)
|
92
93
|
c.before do
|
93
94
|
reset_validation_setup_for(Person)
|
94
95
|
reset_validation_setup_for(PersonWithShim)
|
@@ -7,7 +7,11 @@ RSpec.describe ValidatesTimeliness::Converter do
|
|
7
7
|
let(:ignore_usec) { false }
|
8
8
|
|
9
9
|
before do
|
10
|
-
|
10
|
+
travel_to Time.mktime(2010, 1, 1, 0, 0, 0)
|
11
|
+
end
|
12
|
+
|
13
|
+
after do
|
14
|
+
travel_back
|
11
15
|
end
|
12
16
|
|
13
17
|
delegate :type_cast_value, :evaluate, :parse, :dummy_time, to: :converter
|
@@ -195,10 +199,6 @@ RSpec.describe ValidatesTimeliness::Converter do
|
|
195
199
|
end
|
196
200
|
|
197
201
|
context "restriction shorthand" do
|
198
|
-
before do
|
199
|
-
Timecop.freeze(Time.mktime(2010, 1, 1, 0, 0, 0))
|
200
|
-
end
|
201
|
-
|
202
202
|
it 'should evaluate :now as current time' do
|
203
203
|
expect(evaluate(:now, person)).to eq(Time.now)
|
204
204
|
end
|
@@ -115,7 +115,11 @@ RSpec.describe 'ValidatesTimeliness::Extensions::DateTimeSelect' do
|
|
115
115
|
|
116
116
|
describe "time_select" do
|
117
117
|
before do
|
118
|
-
|
118
|
+
travel_to Time.mktime(2009,1,1)
|
119
|
+
end
|
120
|
+
|
121
|
+
after do
|
122
|
+
travel_back
|
119
123
|
end
|
120
124
|
|
121
125
|
it "should use param values when attribute is nil" do
|
@@ -158,5 +162,5 @@ RSpec.describe 'ValidatesTimeliness::Extensions::DateTimeSelect' do
|
|
158
162
|
expect(@output).not_to have_tag("select[id=person_#{attribute}_#{index}i] option[selected=selected]")
|
159
163
|
end
|
160
164
|
end
|
161
|
-
|
165
|
+
|
162
166
|
end
|
@@ -3,19 +3,29 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
require "validates_timeliness/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
+
|
7
|
+
github_url = 'https://github.com/adzap/validates_timeliness'
|
8
|
+
|
6
9
|
s.name = "validates_timeliness"
|
7
10
|
s.version = ValidatesTimeliness::VERSION
|
8
11
|
s.authors = ["Adam Meehan"]
|
9
12
|
s.summary = %q{Date and time validation plugin for Rails which allows custom formats}
|
10
13
|
s.description = %q{Adds validation methods to ActiveModel for validating dates and times. Works with multiple ORMS.}
|
11
14
|
s.email = %q{adam.meehan@gmail.com}
|
12
|
-
s.homepage =
|
15
|
+
s.homepage = github_url
|
13
16
|
s.license = "MIT"
|
14
17
|
|
15
18
|
s.require_paths = ["lib"]
|
16
19
|
s.files = `git ls-files`.split("\n") - %w{ .gitignore .rspec Gemfile Gemfile.lock autotest/discover.rb Appraisals } - Dir['gemsfiles/*']
|
17
20
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
-
s.extra_rdoc_files = ["README.md", "CHANGELOG.
|
21
|
+
s.extra_rdoc_files = ["README.md", "CHANGELOG.md", "LICENSE"]
|
22
|
+
|
23
|
+
s.metadata = {
|
24
|
+
"bug_tracker_uri" => "#{github_url}/issues",
|
25
|
+
"changelog_uri" => "#{github_url}/blob/master/CHANGELOG.md",
|
26
|
+
"source_code_uri" => "#{github_url}",
|
27
|
+
"wiki_uri" => "#{github_url}/wiki",
|
28
|
+
}
|
19
29
|
|
20
30
|
s.add_runtime_dependency("activemodel", [">= 6.0.0", "< 7"])
|
21
31
|
s.add_runtime_dependency("timeliness", [">= 0.3.10", "< 1"])
|
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: 6.0.0
|
4
|
+
version: 6.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: 2022-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -57,12 +57,12 @@ executables: []
|
|
57
57
|
extensions: []
|
58
58
|
extra_rdoc_files:
|
59
59
|
- README.md
|
60
|
-
- CHANGELOG.
|
60
|
+
- CHANGELOG.md
|
61
61
|
- LICENSE
|
62
62
|
files:
|
63
63
|
- ".github/dependabot.yml"
|
64
64
|
- ".github/workflows/ci.yml"
|
65
|
-
- CHANGELOG.
|
65
|
+
- CHANGELOG.md
|
66
66
|
- LICENSE
|
67
67
|
- README.md
|
68
68
|
- Rakefile
|
@@ -105,10 +105,14 @@ files:
|
|
105
105
|
- spec/validates_timeliness/validator_spec.rb
|
106
106
|
- spec/validates_timeliness_spec.rb
|
107
107
|
- validates_timeliness.gemspec
|
108
|
-
homepage:
|
108
|
+
homepage: https://github.com/adzap/validates_timeliness
|
109
109
|
licenses:
|
110
110
|
- MIT
|
111
|
-
metadata:
|
111
|
+
metadata:
|
112
|
+
bug_tracker_uri: https://github.com/adzap/validates_timeliness/issues
|
113
|
+
changelog_uri: https://github.com/adzap/validates_timeliness/blob/master/CHANGELOG.md
|
114
|
+
source_code_uri: https://github.com/adzap/validates_timeliness
|
115
|
+
wiki_uri: https://github.com/adzap/validates_timeliness/wiki
|
112
116
|
post_install_message:
|
113
117
|
rdoc_options: []
|
114
118
|
require_paths:
|
@@ -120,11 +124,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
124
|
version: '0'
|
121
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
126
|
requirements:
|
123
|
-
- - "
|
127
|
+
- - ">="
|
124
128
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
129
|
+
version: '0'
|
126
130
|
requirements: []
|
127
|
-
rubygems_version: 3.
|
131
|
+
rubygems_version: 3.1.6
|
128
132
|
signing_key:
|
129
133
|
specification_version: 4
|
130
134
|
summary: Date and time validation plugin for Rails which allows custom formats
|
data/CHANGELOG.rdoc
DELETED
@@ -1,222 +0,0 @@
|
|
1
|
-
= 5.0.0 [2021-04-03]
|
2
|
-
* Fix DateTimeSelect extension support (AquisTech)
|
3
|
-
* Relaxed Timeliness dependency version which allows for >= 0.4.0 with
|
4
|
-
threadsafety fix for use_us_formats and use_euro_formats for hot switching
|
5
|
-
in a request.
|
6
|
-
* Add initializer to ensure Timeliness v0.4+ ambiguous date config is set
|
7
|
-
correctly when using `use_euro_formats` or `remove_use_formats'.
|
8
|
-
* Add Ruby 3 compatibility
|
9
|
-
* Add Rails 6.1 compatibility
|
10
|
-
|
11
|
-
Breaking Changes
|
12
|
-
* Update Multiparameter extension to use ActiveRecord type classes with multiparameter handling
|
13
|
-
which stores a hash of multiparamter values as the value before type cast, no longer a mushed datetime string
|
14
|
-
* Removed all custom plugin attribute methods and method overrides in favour using ActiveModel type system
|
15
|
-
|
16
|
-
= 4.1.0 [2019-06-11]
|
17
|
-
* Relaxed Timeliness dependency version to >= 0.3.10 and < 1, which allows
|
18
|
-
version 0.4 with threadsafety fix for use_us_formats and use_euro_formats
|
19
|
-
hot switching in a request.
|
20
|
-
|
21
|
-
= 4.0.2 [2016-01-07]
|
22
|
-
* Fix undefine_generated_methods ivar guard setting to false
|
23
|
-
|
24
|
-
= 4.0.1 [2016-01-06]
|
25
|
-
* Fix undefine_generated_methods thread locking bug
|
26
|
-
* Created an ActiveModel ORM, for manual require if using without any full blown ORM
|
27
|
-
|
28
|
-
= 4.0.0 [2015-12-29]
|
29
|
-
* Extracted mongoid support into https://github.com/adzap/validates_timeliness-mongoid which is broken (not supported anymore).
|
30
|
-
* Fixed Rails 4.0, 4.1 and 4.2 compatability issues
|
31
|
-
* Upgrade specs to RSpec 3
|
32
|
-
* Added travis config
|
33
|
-
* Huge thanks to @johncarney for keeping it alive with his fork (https://github.com/johncarney/validates_timeliness)
|
34
|
-
|
35
|
-
= 3.0.15 [2015-12-29]
|
36
|
-
* Fixes mongoid 3 support and removes mongoid 2 support(johnnyshields)
|
37
|
-
* Some documentation/comments tidying
|
38
|
-
* Some general tidying up
|
39
|
-
|
40
|
-
= 3.0.14 [2012-08-23]
|
41
|
-
* Fix for using validates :timeliness => {} form to correctly add attributes to timeliness validated attributes.
|
42
|
-
|
43
|
-
= 3.0.13 [2012-08-21]
|
44
|
-
* Fix ActiveRecord issues with using plugin parser by using old way of caching values.
|
45
|
-
* Allow any ActiveRecord non-column attribute to be validated
|
46
|
-
|
47
|
-
= 3.0.12 [2012-06-23]
|
48
|
-
* Fix load order issue when relying on Railtie to load ActiveRecord extension
|
49
|
-
|
50
|
-
= 3.0.11 [2012-04-01]
|
51
|
-
* Change dependency on Timeliness version due to a broken release
|
52
|
-
|
53
|
-
= 3.0.10 [2012-03-26]
|
54
|
-
* Fix for ActiveRecord shim and validation with :allow_blank => true in AR 3.1+. Fixes issue#52.
|
55
|
-
|
56
|
-
= 3.0.9 [2012-03-26]
|
57
|
-
* ActiveRecord 3.1+ suport
|
58
|
-
* Fixes for multiparameter extension with empty date values (thanks @mogox, @Sharagoz)
|
59
|
-
|
60
|
-
= 3.0.8 [2011-12-24]
|
61
|
-
* Remove deprecated InstanceMethods module when using AS::Concern (carlosantoniodasilva)
|
62
|
-
* Update Mongoid shim for v2.3 compatability.
|
63
|
-
|
64
|
-
= 3.0.7 [2011-09-21]
|
65
|
-
* Fix ActiveRecord before_type_cast extension for non-dirty attributes.
|
66
|
-
* Don't override AR before_type_cast for >= 3.1.0 which now has it's own implementation for date/time attributes.
|
67
|
-
* Fix DateTimeSelect extension to convert params to integers (#45)
|
68
|
-
* Add #change method to DateTimeSelect extension (@trusche, #45)
|
69
|
-
* Cleanup Mongoid shim.
|
70
|
-
|
71
|
-
= 3.0.6 [2011-05-09]
|
72
|
-
* Fix for AR type conversion for date columns when using plugin parser.
|
73
|
-
* Add timeliness_type_cast_code for ORM specific type casting after parsing.
|
74
|
-
|
75
|
-
= 3.0.5 [2011-01-29]
|
76
|
-
* Fix for Conversion#parse when given nil value (closes issue #34)
|
77
|
-
|
78
|
-
= 3.0.4 [2011-01-22]
|
79
|
-
* Fix :between option which was being ignored (ebeigarts)
|
80
|
-
* Use class_attribute to remove deprecated class_inheritable_accessor
|
81
|
-
* Namespace copied validator class to ActiveModel::Validations::Timeliness for :timeliness option
|
82
|
-
|
83
|
-
= 3.0.3 [2010-12-11]
|
84
|
-
* Fix validation of values which don't respond to to_date or to_time (renatoelias)
|
85
|
-
|
86
|
-
= 3.0.2 [2010-12-04]
|
87
|
-
* Fix AR multiparameter extension for Date columns
|
88
|
-
* Update to Timeliness 0.3.2 for zone abbreviation and offset support
|
89
|
-
|
90
|
-
= 3.0.1 [2010-11-02]
|
91
|
-
* Generate timeliness write methods in an included module to allow overriding in model class (josevalim)
|
92
|
-
|
93
|
-
= 3.0.0 [2010-10-18]
|
94
|
-
* Rails 3 and ActiveModel compatibility
|
95
|
-
* Uses ActiveModel::EachValidator as validator base class.
|
96
|
-
* Configuration settings stored in ValidatesTimeliness module only. ValidatesTimeliness.setup block to configure.
|
97
|
-
* Parser extracted to the Timeliness gem http://github.com/adzap/timeliness
|
98
|
-
* Parser is disabled by default. See initializer for enabling it.
|
99
|
-
* Removed RSpec matcher. Encouraged poor specs by copy-pasting from spec to model, or worse, the other way round.
|
100
|
-
* Method override for parsing and before type cast values is on validated attributes only. Old version handled all date/datetime columns, validates or not. Too intrusive.
|
101
|
-
* Add validation helpers to classes using extend_orms config setting. e.g. conf.extend_orms = [ :active_record ]
|
102
|
-
* Changed :between option so it is split into :on_or_after and :on_or_before option values. The error message for either failing check will be used instead of a between error message.
|
103
|
-
* Provides :timeliness option key for validates class method. Be sure to pass :type option as well e.g. :type => :date.
|
104
|
-
* Allows validation methods to be called on record instances as per ActiveModel API.
|
105
|
-
* Performs parsing (optional) and raw value caching (before_type_cast) on validated attributes only. It used to be all date, time and datetime attributes.
|
106
|
-
|
107
|
-
= 2.3.1 [2010-03-19]
|
108
|
-
* Fixed bug where custom attribute writer method for date/times were being overriden
|
109
|
-
|
110
|
-
= 2.3.0 [2010-02-04]
|
111
|
-
* Backwards incompatible change to :equal_to option. Fixed error message clash with :equal_to option which exists in Rails already. Option is now :is_at.
|
112
|
-
* Fixed I18n support so it returns missing translation message instead of error
|
113
|
-
* Fixed attribute method bug. Write method was bypassed when method was first generated and used Rails default parser.
|
114
|
-
* Fixed date/time selects when using enable_datetime_select_extension! when some values empty
|
115
|
-
* Fixed ISO8601 datetime format which is now split into two formats
|
116
|
-
* Changed I18n error value format to fallback to global default if missing in locale
|
117
|
-
* Refactored date/time select invalid value extension to use param values. Functionality will be extracted from plugin for v3.
|
118
|
-
|
119
|
-
= 2.2.2 [2009-09-19]
|
120
|
-
* Fixed dummy_time using make_time to respect timezone. Fixes 1.9.1 bug.
|
121
|
-
|
122
|
-
= 2.2.1 [2009-09-12]
|
123
|
-
* Fixed dummy date part for time types in Validator.type_cast_value
|
124
|
-
* No more core extensions! Removed dummy_time methods.
|
125
|
-
|
126
|
-
= 2.2.0 [2009-09-12]
|
127
|
-
* Ruby 1.9 support!
|
128
|
-
* Customise dummy date values for time types. See DUMMY DATE FOR TIME TYPES.
|
129
|
-
* Fixed matcher conflict with Shoulda. Load plugin matcher manually now see matcher section in README
|
130
|
-
* Fixed :ignore_usec when used with :with_time or :with_date
|
131
|
-
* Some clean up and refactoring
|
132
|
-
|
133
|
-
= 2.1.0 [2009-06-20]
|
134
|
-
* Added ambiguous year threshold setting in Formats class to customize the threshold for 2 digit years (See README)
|
135
|
-
* Fixed interpolation values in custom error message for Rails 2.2+
|
136
|
-
* Fixed custom I18n local override of en locale
|
137
|
-
* Dramatically simplified ActiveRecord monkey patching and hackery
|
138
|
-
|
139
|
-
= 2.0.0 [2009-04-12]
|
140
|
-
* Error value formats are now specified in the i18n locale file instead of updating plugin hash. See OTHER CUSTOMISATION section in README.
|
141
|
-
* Date/time select helper extension is disabled by default. To enable see DISPLAY INVALID VALUES IN DATE HELPERS section in README to enable.
|
142
|
-
* Added :format option to limit validation to a single format if desired
|
143
|
-
* Matcher now supports :equal_to option
|
144
|
-
* Formats.parse can take :include_offset option to include offset value from string in seconds, if string contains an offset. Offset not used in rest of plugin yet.
|
145
|
-
* Refactored to remove as much plugin code from ActiveRecord as possible.
|
146
|
-
|
147
|
-
= 1.1.7 [2009-03-26]
|
148
|
-
* Minor change to multiparameter attributes which I had not properly implemented for chaining
|
149
|
-
|
150
|
-
= 1.1.6 [2009-03-19]
|
151
|
-
* Rail 2.3 support
|
152
|
-
* Added :with_date and :with_time options. They allow an attribute to be combined with another attribute or value to make a datetime value for validation against the temporal restrictions
|
153
|
-
* Added :equal_to option
|
154
|
-
* Option key validation
|
155
|
-
* Better behaviour with other plugins using alias_method_chain on read_attribute and define_attribute_methods
|
156
|
-
* Added option to enable datetime_select extension for future use to optionally enable. Enabled by default until version 2.
|
157
|
-
* Added :ignore_usec option for datetime restrictions to be compared without microsecond
|
158
|
-
* some refactoring
|
159
|
-
|
160
|
-
= 1.1.5 [2009-01-21]
|
161
|
-
* Fixed regex for 'yy' format token which wasn't greedy enough for date formats ending with year when a datetime string parsed as date with a 4 digit year
|
162
|
-
|
163
|
-
= 1.1.4 [2009-01-13]
|
164
|
-
* Make months names respect i18n in Formats
|
165
|
-
|
166
|
-
= 1.1.3 [2009-01-13]
|
167
|
-
* Fixed bug where time and date attributes still being parsed on read using Rails default parser [reported by Brad (pvjq)]
|
168
|
-
|
169
|
-
= 1.1.2 [2009-01-12]
|
170
|
-
* Fixed bugs
|
171
|
-
* matcher failing for custom error message without interpolation keys using I18n
|
172
|
-
* validator custom error messages not being extracted
|
173
|
-
|
174
|
-
= 1.1.1 [2009-01-03]
|
175
|
-
* Fixed bug in matcher for options local variable
|
176
|
-
|
177
|
-
= 1.1.0 [2009-01-01]
|
178
|
-
* Added between option
|
179
|
-
|
180
|
-
= 1.0.0 [2008-12-06]
|
181
|
-
* Gemified!
|
182
|
-
* Refactor of plugin into a Data Mapper style validator class which makes for a cleaner implementation and possible future Merb\Data Mapper support
|
183
|
-
* Added Rails 2.2 i18n support. Plugin error messages can specified in locale files. See README.
|
184
|
-
* ignore_datetime_restriction_errors setting has been moved from AR to ValidatesTimeliness::Validator.ignore_restriction_errors
|
185
|
-
* date_time_error_value_formats setting has been moved from AR to ValidatesTimeliness::Validator.error_value_formats
|
186
|
-
* Namespaced modules and specs
|
187
|
-
* Clean up of specs
|
188
|
-
* fixed a few bugs
|
189
|
-
* accessor methods not generating properly due method name stored as symbol in generated_attributes which fails on lookup
|
190
|
-
* force value assigned to time/datetime attributes to time objects
|
191
|
-
|
192
|
-
= 0.1.0 [2008-12-06]
|
193
|
-
* Tagged plugin as version 0.1.0
|
194
|
-
|
195
|
-
= 2008-11-13
|
196
|
-
* allow uppercase meridian to be valid [reported by Alex (http://alex.digns.com/)]
|
197
|
-
|
198
|
-
= 2008-10-28
|
199
|
-
* fixed bug when dirty attributes not reflecting change when attribute changed from time value to nil [reported by Brad (pvjq)]
|
200
|
-
* fixes for Rails 2.2 compatibility. Will refactor in to Rails version specific branches in the future.
|
201
|
-
|
202
|
-
= 2008-09-24
|
203
|
-
* refactored attribute write method definitions
|
204
|
-
|
205
|
-
= 2008-08-25
|
206
|
-
* fixed bug for non-timezone write method not updating changed attributes hash [reported by Sylvestre Mergulhão]
|
207
|
-
|
208
|
-
= 2008-08-22
|
209
|
-
* fixed bug with attribute cache not clearing on write for date and time columns [reported by Sylvestre Mergulhão]
|
210
|
-
* parse method returns Date object for date column assigned string as per normal Rails behaviour
|
211
|
-
* parse method returns same object type when assigned Date or Time object as per normal Rails behaviour
|
212
|
-
|
213
|
-
= 2008-08-07
|
214
|
-
* modified matcher option value parsing to allow same value types as validation method
|
215
|
-
* fixed matcher message
|
216
|
-
|
217
|
-
= 2008-08-02
|
218
|
-
* refactored validation
|
219
|
-
* refactored matcher
|
220
|
-
|
221
|
-
= 2008-07-30
|
222
|
-
* removed setting values to nil when validation fails to preserve before_type_cast value
|