validates_timeliness 7.0.0.beta1 → 8.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/.github/workflows/ci.yml +4 -6
- data/CHANGELOG.md +14 -0
- data/README.md +3 -2
- data/gemfiles/{rails_7_0.gemfile → rails_8_0.gemfile} +4 -4
- data/lib/validates_timeliness/extensions/date_time_select.rb +1 -1
- data/lib/validates_timeliness/extensions.rb +3 -2
- data/lib/validates_timeliness/helper_methods.rb +4 -10
- data/lib/validates_timeliness/orm/active_model.rb +1 -60
- data/lib/validates_timeliness/validator.rb +16 -6
- data/lib/validates_timeliness/version.rb +1 -1
- data/spec/spec_helper.rb +1 -4
- data/spec/support/model_helpers.rb +15 -8
- data/spec/support/test_model.rb +4 -52
- data/spec/validates_timeliness/attribute_methods_spec.rb +4 -0
- data/spec/validates_timeliness/validator/format_spec.rb +57 -0
- data/spec/validates_timeliness/validator_spec.rb +20 -0
- data/validates_timeliness.gemspec +2 -1
- metadata +13 -11
- data/gemfiles/rails_edge.gemfile +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fddd24dc1daff9d9c90db6d6cb477519ab77abcf5dc8c55c5c69af61504eba46
|
4
|
+
data.tar.gz: e16bbad97a83834a912610ff682fe2c93ef7204e0b19f070becd84e4e3ebaf18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 443d66dd2feb66c01e77294236fbf7b197e358246dbd40b9014c5b888e23810219851d89dd320db9e0a256bc62a6402fdbcc326684941566dbdc331285faefce
|
7
|
+
data.tar.gz: 0d1f13688d2a26ffaa940b409c9f6139cd780b21ffffb1ef02470718bd63d3d1e86bf2bcf4e411b15de4cb7badb215cdd7df8088f59ff63f044f924fcbdf570d
|
data/.github/workflows/ci.yml
CHANGED
@@ -7,12 +7,10 @@ jobs:
|
|
7
7
|
fail-fast: false
|
8
8
|
matrix:
|
9
9
|
include:
|
10
|
-
- gemfile:
|
11
|
-
ruby: 2
|
12
|
-
- gemfile:
|
13
|
-
ruby: 3.
|
14
|
-
- gemfile: rails_7_0
|
15
|
-
ruby: 3.1
|
10
|
+
- gemfile: rails_8_0
|
11
|
+
ruby: 3.2
|
12
|
+
- gemfile: rails_8_0
|
13
|
+
ruby: 3.3
|
16
14
|
|
17
15
|
name: ${{ matrix.gemfile }}, ruby ${{ matrix.ruby }}
|
18
16
|
env:
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
# 8.0.0 [2024-12-31]
|
2
|
+
* Support Rails v8.x
|
3
|
+
* Support passing non-reserved validation options to errors
|
4
|
+
|
5
|
+
# 7.0.0 [2024-11-30]
|
6
|
+
* Support Rails v7.x
|
7
|
+
* Removed all method overrides in ActiveModel now that the datetime type correctly stores before_type_cast values.
|
8
|
+
|
9
|
+
# 6.0.1 [2023-01-12]
|
10
|
+
* TODO need to complete this
|
11
|
+
|
12
|
+
# 6.0.0 [2022-10-20]
|
13
|
+
* TODO need to complete this
|
14
|
+
|
1
15
|
# 5.0.0 [2021-04-03]
|
2
16
|
* Fix DateTimeSelect extension support (AquisTech)
|
3
17
|
* Relaxed Timeliness dependency version which allows for >= 0.4.0 with
|
data/README.md
CHANGED
@@ -6,13 +6,14 @@
|
|
6
6
|
|
7
7
|
## Description
|
8
8
|
|
9
|
-
Complete validation of dates, times and datetimes for Rails
|
9
|
+
Complete validation of dates, times and datetimes for Rails 8.x and ActiveModel.
|
10
10
|
|
11
11
|
Older Rails versions:
|
12
12
|
|
13
13
|
- Rails 4.x: [https://github.com/adzap/validates_timeliness/tree/4-0-stable]
|
14
14
|
- Rails 5.x: [https://github.com/adzap/validates_timeliness/tree/5-0-stable]
|
15
15
|
- Rails 6.x: [https://github.com/adzap/validates_timeliness/tree/6-0-stable]
|
16
|
+
- Rails 7.x: [https://github.com/adzap/validates_timeliness/tree/7-0-stable]
|
16
17
|
|
17
18
|
|
18
19
|
## Features
|
@@ -30,7 +31,7 @@ Older Rails versions:
|
|
30
31
|
|
31
32
|
In Gemfile
|
32
33
|
```ruby
|
33
|
-
gem 'validates_timeliness', '~>
|
34
|
+
gem 'validates_timeliness', '~> 8.0.0.beta1'
|
34
35
|
```
|
35
36
|
|
36
37
|
Run bundler:
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# This file was generated by Appraisal
|
2
2
|
|
3
|
-
source "
|
3
|
+
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "rails", "~>
|
5
|
+
gem "rails", "~> 8.0.0"
|
6
6
|
gem "rspec"
|
7
7
|
gem "rspec-rails", "~> 6.0"
|
8
|
-
gem "sqlite3"
|
8
|
+
gem "sqlite3", "~> 2.0"
|
9
9
|
gem "byebug"
|
10
10
|
gem "appraisal"
|
11
|
-
gem "nokogiri"
|
11
|
+
gem "nokogiri"
|
12
12
|
|
13
13
|
gemspec path: "../"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module ValidatesTimeliness
|
2
2
|
module Extensions
|
3
|
-
module
|
3
|
+
module DateTimeSelect
|
4
4
|
# Intercepts the date and time select helpers to reuse the values from
|
5
5
|
# the params rather than the parsed value. This allows invalid date/time
|
6
6
|
# values to be redisplayed instead of blanks to aid correction by the user.
|
@@ -1,10 +1,11 @@
|
|
1
1
|
module ValidatesTimeliness
|
2
2
|
module Extensions
|
3
|
-
autoload :
|
3
|
+
autoload :DateTimeSelect, 'validates_timeliness/extensions/date_time_select'
|
4
4
|
end
|
5
5
|
|
6
6
|
def self.enable_date_time_select_extension!
|
7
|
-
|
7
|
+
require 'uri' # Do we need this? No, but the test suite fails without it.
|
8
|
+
::ActionView::Helpers::Tags::DateSelect.send(:prepend, ValidatesTimeliness::Extensions::DateTimeSelect)
|
8
9
|
end
|
9
10
|
|
10
11
|
def self.enable_multiparameter_extension!
|
@@ -3,25 +3,19 @@ module ActiveModel
|
|
3
3
|
|
4
4
|
module HelperMethods
|
5
5
|
def validates_date(*attr_names)
|
6
|
-
|
6
|
+
validates_with TimelinessValidator, _merge_attributes(attr_names).merge(type: :date)
|
7
7
|
end
|
8
8
|
|
9
9
|
def validates_time(*attr_names)
|
10
|
-
|
10
|
+
validates_with TimelinessValidator, _merge_attributes(attr_names).merge(type: :time)
|
11
11
|
end
|
12
12
|
|
13
13
|
def validates_datetime(*attr_names)
|
14
|
-
|
14
|
+
validates_with TimelinessValidator, _merge_attributes(attr_names).merge(type: :datetime)
|
15
15
|
end
|
16
16
|
|
17
17
|
def validates_timeliness_of(*attr_names)
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
def timeliness_validation_for(attr_names, type=nil)
|
22
|
-
options = _merge_attributes(attr_names)
|
23
|
-
options.update(:type => type) if type
|
24
|
-
validates_with TimelinessValidator, options
|
18
|
+
validates_with TimelinessValidator, _merge_attributes(attr_names)
|
25
19
|
end
|
26
20
|
end
|
27
21
|
|
@@ -3,67 +3,8 @@ module ValidatesTimeliness
|
|
3
3
|
module ActiveModel
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
|
-
module ClassMethods
|
7
|
-
public
|
8
|
-
|
9
|
-
def define_attribute_methods(*attr_names)
|
10
|
-
super.tap { define_timeliness_methods }
|
11
|
-
end
|
12
|
-
|
13
|
-
def undefine_attribute_methods
|
14
|
-
super.tap { undefine_timeliness_attribute_methods }
|
15
|
-
end
|
16
|
-
|
17
|
-
def define_timeliness_methods(before_type_cast=false)
|
18
|
-
return if timeliness_validated_attributes.blank?
|
19
|
-
timeliness_validated_attributes.each do |attr_name|
|
20
|
-
define_attribute_timeliness_methods(attr_name, before_type_cast)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def generated_timeliness_methods
|
25
|
-
@generated_timeliness_methods ||= Module.new { |m|
|
26
|
-
extend Mutex_m
|
27
|
-
}.tap { |mod| include mod }
|
28
|
-
end
|
29
|
-
|
30
|
-
def undefine_timeliness_attribute_methods
|
31
|
-
generated_timeliness_methods.module_eval do
|
32
|
-
instance_methods.each { |m| undef_method(m) }
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def define_attribute_timeliness_methods(attr_name, before_type_cast=false)
|
37
|
-
define_timeliness_write_method(attr_name)
|
38
|
-
define_timeliness_before_type_cast_method(attr_name) if before_type_cast
|
39
|
-
end
|
40
|
-
|
41
|
-
def define_timeliness_write_method(attr_name)
|
42
|
-
generated_timeliness_methods.module_eval <<-STR, __FILE__, __LINE__ + 1
|
43
|
-
def #{attr_name}=(value)
|
44
|
-
@timeliness_cache ||= {}
|
45
|
-
@timeliness_cache['#{attr_name}'] = value
|
46
|
-
|
47
|
-
@attributes['#{attr_name}'] = super
|
48
|
-
end
|
49
|
-
STR
|
50
|
-
end
|
51
|
-
|
52
|
-
def define_timeliness_before_type_cast_method(attr_name)
|
53
|
-
generated_timeliness_methods.module_eval <<-STR, __FILE__, __LINE__ + 1
|
54
|
-
def #{attr_name}_before_type_cast
|
55
|
-
read_timeliness_attribute_before_type_cast('#{attr_name}')
|
56
|
-
end
|
57
|
-
STR
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
6
|
def read_timeliness_attribute_before_type_cast(attr_name)
|
62
|
-
@
|
63
|
-
end
|
64
|
-
|
65
|
-
def _clear_timeliness_cache
|
66
|
-
@timeliness_cache = {}
|
7
|
+
@attributes[attr_name].value_before_type_cast
|
67
8
|
end
|
68
9
|
|
69
10
|
end
|
@@ -21,6 +21,8 @@ module ValidatesTimeliness
|
|
21
21
|
|
22
22
|
RESTRICTION_ERROR_MESSAGE = "Error occurred validating %s for %s restriction:\n%s"
|
23
23
|
|
24
|
+
RESERVED_OPTIONS = (RESTRICTIONS.keys + RESTRICTIONS.keys.map { |option| :"#{option}_message" }).freeze
|
25
|
+
|
24
26
|
def self.kind
|
25
27
|
:timeliness
|
26
28
|
end
|
@@ -72,7 +74,7 @@ module ValidatesTimeliness
|
|
72
74
|
begin
|
73
75
|
restriction_value = @converter.type_cast_value(@converter.evaluate(options[restriction], record))
|
74
76
|
unless value.send(RESTRICTIONS[restriction], restriction_value)
|
75
|
-
add_error(record, attr_name, restriction, restriction_value) and break
|
77
|
+
add_error(record, attr_name, restriction, value: value, restriction_value: restriction_value) and break
|
76
78
|
end
|
77
79
|
rescue => e
|
78
80
|
unless ValidatesTimeliness.ignore_restriction_errors
|
@@ -83,20 +85,28 @@ module ValidatesTimeliness
|
|
83
85
|
end
|
84
86
|
end
|
85
87
|
|
86
|
-
def add_error(record, attr_name, message, value
|
87
|
-
|
88
|
-
|
89
|
-
|
88
|
+
def add_error(record, attr_name, message, restriction_value: nil, value: nil)
|
89
|
+
error_options = options.except(*RESERVED_OPTIONS).merge!(
|
90
|
+
restriction: format_error_value(restriction_value),
|
91
|
+
value: value
|
92
|
+
)
|
93
|
+
|
94
|
+
message_text = options[:"#{message}_message"]
|
95
|
+
error_options[:message] = message_text if message_text.present?
|
96
|
+
|
97
|
+
record.errors.add(attr_name, message, **error_options)
|
90
98
|
end
|
91
99
|
|
92
100
|
def format_error_value(value)
|
101
|
+
return unless value
|
93
102
|
format = I18n.t(@type, default: DEFAULT_ERROR_VALUE_FORMATS[@type], scope: 'validates_timeliness.error_value_formats')
|
94
103
|
value.strftime(format)
|
95
104
|
end
|
96
105
|
|
97
106
|
def attribute_raw_value(record, attr_name)
|
98
|
-
record.respond_to?(:read_timeliness_attribute_before_type_cast)
|
107
|
+
if record.respond_to?(:read_timeliness_attribute_before_type_cast)
|
99
108
|
record.read_timeliness_attribute_before_type_cast(attr_name.to_s)
|
109
|
+
end
|
100
110
|
end
|
101
111
|
|
102
112
|
def time_zone_aware?(record, attr_name)
|
data/spec/spec_helper.rb
CHANGED
@@ -33,8 +33,6 @@ I18n.available_locales = ['en', 'es']
|
|
33
33
|
# Extend TestModel as you would another ORM/ODM module
|
34
34
|
module TestModelShim
|
35
35
|
extend ActiveSupport::Concern
|
36
|
-
include ValidatesTimeliness::AttributeMethods
|
37
|
-
include ValidatesTimeliness::ORM::ActiveModel
|
38
36
|
|
39
37
|
module ClassMethods
|
40
38
|
# Hook into native time zone handling check, if any
|
@@ -46,11 +44,10 @@ end
|
|
46
44
|
|
47
45
|
class Person
|
48
46
|
include TestModel
|
47
|
+
|
49
48
|
attribute :birth_date, :date
|
50
49
|
attribute :birth_time, :time
|
51
50
|
attribute :birth_datetime, :datetime
|
52
|
-
|
53
|
-
define_attribute_methods model_attributes.keys
|
54
51
|
end
|
55
52
|
|
56
53
|
class PersonWithShim < Person
|
@@ -1,22 +1,29 @@
|
|
1
1
|
module ModelHelpers
|
2
2
|
|
3
3
|
# Some test helpers from Rails source
|
4
|
-
def invalid!(attr_name, values, error = nil)
|
5
|
-
|
6
|
-
expect(record).
|
4
|
+
def invalid!(attr_name, values, error = nil, model_class = Person)
|
5
|
+
with_each_model_value(attr_name, values, model_class) do |record, value|
|
6
|
+
expect(record).to_not be_valid
|
7
7
|
expect(record.errors[attr_name].size).to be >= 1
|
8
|
-
|
8
|
+
|
9
|
+
return unless error
|
10
|
+
|
11
|
+
if error.is_a?(Regexp)
|
12
|
+
expect(record.errors[attr_name].first).to match(error)
|
13
|
+
else
|
14
|
+
expect(record.errors[attr_name].first).to eq(error)
|
15
|
+
end
|
9
16
|
end
|
10
17
|
end
|
11
18
|
|
12
|
-
def valid!(attr_name, values)
|
13
|
-
|
19
|
+
def valid!(attr_name, values, model_class = Person)
|
20
|
+
with_each_model_value(attr_name, values, model_class) do |record, value|
|
14
21
|
expect(record).to be_valid
|
15
22
|
end
|
16
23
|
end
|
17
24
|
|
18
|
-
def
|
19
|
-
record =
|
25
|
+
def with_each_model_value(attr_name, values, model_class)
|
26
|
+
record = model_class.new
|
20
27
|
Array.wrap(values).each do |value|
|
21
28
|
record.send("#{attr_name}=", value)
|
22
29
|
yield record, value
|
data/spec/support/test_model.rb
CHANGED
@@ -1,61 +1,13 @@
|
|
1
1
|
module TestModel
|
2
2
|
extend ActiveSupport::Concern
|
3
|
-
|
3
|
+
include ActiveModel::Model
|
4
|
+
include ActiveModel::Attributes
|
4
5
|
include ActiveModel::Validations
|
5
|
-
include
|
6
|
+
include ValidatesTimeliness::AttributeMethods
|
7
|
+
include ValidatesTimeliness::ORM::ActiveModel
|
6
8
|
|
7
9
|
included do
|
8
10
|
attribute_method_suffix "="
|
9
|
-
cattr_accessor :model_attributes
|
10
|
-
end
|
11
|
-
|
12
|
-
module ClassMethods
|
13
|
-
def attribute(name, type)
|
14
|
-
self.model_attributes ||= {}
|
15
|
-
self.model_attributes[name] = type
|
16
|
-
end
|
17
|
-
|
18
|
-
def define_method_attribute=(attr_name, owner: nil)
|
19
|
-
generated_attribute_methods.module_eval("def #{attr_name}=(new_value); @attributes['#{attr_name}']=self.class.type_cast('#{attr_name}', new_value); end", __FILE__, __LINE__)
|
20
|
-
end
|
21
|
-
|
22
|
-
def define_method_attribute(attr_name, owner: nil)
|
23
|
-
generated_attribute_methods.module_eval("def #{attr_name}; @attributes['#{attr_name}']; end", __FILE__, __LINE__)
|
24
|
-
end
|
25
|
-
|
26
|
-
def type_cast(attr_name, value)
|
27
|
-
return value unless value.is_a?(String)
|
28
|
-
type_name = model_attributes[attr_name.to_sym]
|
29
|
-
type = ActiveModel::Type.lookup(type_name)
|
30
|
-
type.cast(value)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def initialize(attributes = nil)
|
35
|
-
@attributes = self.class.model_attributes.keys.inject({}) do |hash, column|
|
36
|
-
hash[column.to_s] = nil
|
37
|
-
hash
|
38
|
-
end
|
39
|
-
self.attributes = attributes unless attributes.nil?
|
40
|
-
end
|
41
|
-
|
42
|
-
def attributes
|
43
|
-
@attributes
|
44
|
-
end
|
45
|
-
|
46
|
-
def attributes=(new_attributes={})
|
47
|
-
new_attributes.each do |key, value|
|
48
|
-
send "#{key}=", value
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def method_missing(method_id, *args, &block)
|
53
|
-
if !matched_attribute_method(method_id.to_s).nil?
|
54
|
-
self.class.define_attribute_methods self.class.model_attributes.keys
|
55
|
-
send(method_id, *args, &block)
|
56
|
-
else
|
57
|
-
super
|
58
|
-
end
|
59
11
|
end
|
60
12
|
end
|
61
13
|
|
@@ -44,9 +44,11 @@ RSpec.describe ValidatesTimeliness::AttributeMethods do
|
|
44
44
|
class PersonWithParser
|
45
45
|
include TestModel
|
46
46
|
include TestModelShim
|
47
|
+
|
47
48
|
attribute :birth_date, :date
|
48
49
|
attribute :birth_time, :time
|
49
50
|
attribute :birth_datetime, :datetime
|
51
|
+
|
50
52
|
validates_date :birth_date
|
51
53
|
validates_time :birth_time
|
52
54
|
validates_datetime :birth_datetime
|
@@ -54,8 +56,10 @@ RSpec.describe ValidatesTimeliness::AttributeMethods do
|
|
54
56
|
|
55
57
|
it 'should parse a string value' do
|
56
58
|
expect(Timeliness::Parser).to receive(:parse)
|
59
|
+
|
57
60
|
r = PersonWithParser.new
|
58
61
|
r.birth_date = '2010-01-01'
|
62
|
+
r.birth_date # parsing happens on read not write
|
59
63
|
end
|
60
64
|
|
61
65
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
RSpec.describe ValidatesTimeliness::Validator, ":format option" do
|
2
|
+
with_config(:use_plugin_parser, true)
|
3
|
+
|
4
|
+
describe "for date type" do
|
5
|
+
before do
|
6
|
+
Person.validates_date :birth_date, format: "yyyy-mm-dd"
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should not be valid for string given in the wrong format" do
|
10
|
+
invalid!(:birth_date, '23/12/2023', /is not a valid date/)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should be valid for string given in the right format" do
|
14
|
+
valid!(:birth_date, '2023-12-23')
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should be valid for date instance" do
|
18
|
+
valid!(:birth_date, Date.new(2022,12,23))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "for time type" do
|
23
|
+
before do
|
24
|
+
Person.validates_time :birth_time, format: "hh:nn:ss"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should not be valid for string given in the wrong format" do
|
28
|
+
invalid!(:birth_time, "00-00-00", /is not a valid time/)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should be valid for string given in the right format" do
|
32
|
+
valid!(:birth_time, "00:00:00")
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should be valid for date instance" do
|
36
|
+
valid!(:birth_time, Time.new(2010, 1, 1, 0, 0, 0))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "for datetime type" do
|
41
|
+
before do
|
42
|
+
Person.validates_datetime :birth_datetime, format: "yyyy-mm-dd hh:nn:ss"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should not be valid for string given in the wrong format" do
|
46
|
+
invalid!(:birth_datetime, "01-01-2010 00-00-00", /is not a valid datetime/)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should be valid for string given in the right format" do
|
50
|
+
valid!(:birth_datetime, "2010-01-01 00:00:00")
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should be valid for date instance" do
|
54
|
+
valid!(:birth_datetime, DateTime.new(2010, 1, 1, 0, 0, 0))
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -185,6 +185,26 @@ RSpec.describe ValidatesTimeliness::Validator do
|
|
185
185
|
end
|
186
186
|
end
|
187
187
|
|
188
|
+
describe "custom option" do
|
189
|
+
it "should pass custom options to the error" do
|
190
|
+
Person.validates_datetime :birth_datetime, :on_or_before => Time.utc(2010,1,2,3,4,5), :custom => 'option'
|
191
|
+
|
192
|
+
with_each_model_value(:birth_datetime, Time.utc(2010,1,2,3,4,5,10000), Person) do |record, value|
|
193
|
+
expect(record).to_not be_valid
|
194
|
+
expect(record.errors.where(:birth_datetime).first.options).to include(custom: 'option')
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
it "should not pass config options to the error" do
|
199
|
+
Person.validates_datetime :birth_datetime, :on_or_before => Time.utc(2010,1,2,3,4,5), :custom => 'option'
|
200
|
+
|
201
|
+
with_each_model_value(:birth_datetime, Time.utc(2010,1,2,3,4,5,10000), Person) do |record, value|
|
202
|
+
expect(record).to_not be_valid
|
203
|
+
expect(record.errors.where(:birth_datetime).first.options.keys).to_not include(:on_or_before)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
188
208
|
describe "restriction value errors" do
|
189
209
|
let(:person) { Person.new(:birth_date => Date.today) }
|
190
210
|
|
@@ -21,12 +21,13 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.extra_rdoc_files = ["README.md", "CHANGELOG.md", "LICENSE"]
|
22
22
|
|
23
23
|
s.metadata = {
|
24
|
+
"rubygems_mfa_required" => "true",
|
24
25
|
"bug_tracker_uri" => "#{github_url}/issues",
|
25
26
|
"changelog_uri" => "#{github_url}/blob/master/CHANGELOG.md",
|
26
27
|
"source_code_uri" => "#{github_url}",
|
27
28
|
"wiki_uri" => "#{github_url}/wiki",
|
28
29
|
}
|
29
30
|
|
30
|
-
s.add_runtime_dependency("activemodel", [">=
|
31
|
+
s.add_runtime_dependency("activemodel", [">= 8.0.0", "< 9"])
|
31
32
|
s.add_runtime_dependency("timeliness", [">= 0.3.10", "< 1"])
|
32
33
|
end
|
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:
|
4
|
+
version: 8.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: 2024-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 8.0.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '9'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 8.0.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '9'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: timeliness
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,8 +66,7 @@ files:
|
|
66
66
|
- LICENSE
|
67
67
|
- README.md
|
68
68
|
- Rakefile
|
69
|
-
- gemfiles/
|
70
|
-
- gemfiles/rails_edge.gemfile
|
69
|
+
- gemfiles/rails_8_0.gemfile
|
71
70
|
- init.rb
|
72
71
|
- lib/generators/validates_timeliness/install_generator.rb
|
73
72
|
- lib/generators/validates_timeliness/templates/en.yml
|
@@ -99,6 +98,7 @@ files:
|
|
99
98
|
- spec/validates_timeliness/railtie_spec.rb
|
100
99
|
- spec/validates_timeliness/validator/after_spec.rb
|
101
100
|
- spec/validates_timeliness/validator/before_spec.rb
|
101
|
+
- spec/validates_timeliness/validator/format_spec.rb
|
102
102
|
- spec/validates_timeliness/validator/is_at_spec.rb
|
103
103
|
- spec/validates_timeliness/validator/on_or_after_spec.rb
|
104
104
|
- spec/validates_timeliness/validator/on_or_before_spec.rb
|
@@ -109,6 +109,7 @@ homepage: https://github.com/adzap/validates_timeliness
|
|
109
109
|
licenses:
|
110
110
|
- MIT
|
111
111
|
metadata:
|
112
|
+
rubygems_mfa_required: 'true'
|
112
113
|
bug_tracker_uri: https://github.com/adzap/validates_timeliness/issues
|
113
114
|
changelog_uri: https://github.com/adzap/validates_timeliness/blob/master/CHANGELOG.md
|
114
115
|
source_code_uri: https://github.com/adzap/validates_timeliness
|
@@ -124,11 +125,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
124
125
|
version: '0'
|
125
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
127
|
requirements:
|
127
|
-
- - "
|
128
|
+
- - ">="
|
128
129
|
- !ruby/object:Gem::Version
|
129
|
-
version:
|
130
|
+
version: '0'
|
130
131
|
requirements: []
|
131
|
-
rubygems_version: 3.
|
132
|
+
rubygems_version: 3.4.19
|
132
133
|
signing_key:
|
133
134
|
specification_version: 4
|
134
135
|
summary: Date and time validation plugin for Rails which allows custom formats
|
@@ -148,6 +149,7 @@ test_files:
|
|
148
149
|
- spec/validates_timeliness/railtie_spec.rb
|
149
150
|
- spec/validates_timeliness/validator/after_spec.rb
|
150
151
|
- spec/validates_timeliness/validator/before_spec.rb
|
152
|
+
- spec/validates_timeliness/validator/format_spec.rb
|
151
153
|
- spec/validates_timeliness/validator/is_at_spec.rb
|
152
154
|
- spec/validates_timeliness/validator/on_or_after_spec.rb
|
153
155
|
- spec/validates_timeliness/validator/on_or_before_spec.rb
|
data/gemfiles/rails_edge.gemfile
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "http://rubygems.org"
|
4
|
-
|
5
|
-
gem "rails", git: "https://github.com/rails/rails.git", branch: "main"
|
6
|
-
gem "rspec"
|
7
|
-
gem "rspec-rails", "~> 3.7"
|
8
|
-
gem "sqlite3"
|
9
|
-
gem "byebug"
|
10
|
-
gem "appraisal"
|
11
|
-
gem "nokogiri", "~> 1.8"
|
12
|
-
|
13
|
-
gemspec path: "../"
|