validates_timeliness 7.1.0 → 8.0.0.beta1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d882843a354b86918dd2709809168d5dcbaf024319eeb424b1e0ff56f7731512
4
- data.tar.gz: 0d5c06701e489c7332b59032055a25bcd4c2887f68c95b49a2d4192ecf313d71
3
+ metadata.gz: 446d638f58bf6867dcd02c8d3f89e7c339bde180c4eb56aa49be03860722a8d7
4
+ data.tar.gz: 33c94183ebfc40ee0d90ab1d05ea6e84a65d8e0912fbdc9a7a6338623f403d6f
5
5
  SHA512:
6
- metadata.gz: dc46ee39a4f707078094de96dd795c75f6287343c3a020be49a8455c76a07aad0cd4d26d46b143ca4149c81a8d54c273a32575ef7f0bc23fa63317ccaffc1851
7
- data.tar.gz: 68a0b32a966d7c1a3df5d33c7642eac1c92efa276059b543b8240e73535fa5538e51c580be3362c4011b8f1838bc03817e7b7cc07d7219e68a18b2299cacf6a3
6
+ metadata.gz: 96aba97841df97ade11d86fcf1f28c91c323755f03fc49511fa821383030c3c1eab24d1b88df5e741ab3c2630fb80e86498437c06ded734030044593878c5f66
7
+ data.tar.gz: 020b4690d0b73f82ff21bc8c9c974fe925c6df216a4db0634678158705cc346808ffbc09d74c98fc03ded15867a0ace1e14d1b3da153819bf8667e95bada068d
@@ -7,27 +7,9 @@ jobs:
7
7
  fail-fast: false
8
8
  matrix:
9
9
  include:
10
- - gemfile: rails_7_0
11
- ruby: 2.7
12
- - gemfile: rails_7_0
13
- ruby: 3.0
14
- - gemfile: rails_7_0
15
- ruby: 3.1
16
-
17
- - gemfile: rails_7_1
18
- ruby: 2.7
19
- - gemfile: rails_7_1
20
- ruby: 3.0
21
- - gemfile: rails_7_1
22
- ruby: 3.1
23
- - gemfile: rails_7_1
24
- ruby: 3.2
25
-
26
- - gemfile: rails_7_2
27
- ruby: 3.1
28
- - gemfile: rails_7_2
10
+ - gemfile: rails_8_0
29
11
  ruby: 3.2
30
- - gemfile: rails_7_2
12
+ - gemfile: rails_8_0
31
13
  ruby: 3.3
32
14
 
33
15
  name: ${{ matrix.gemfile }}, ruby ${{ matrix.ruby }}
data/CHANGELOG.md CHANGED
@@ -1,8 +1,4 @@
1
- # 7.1.0 [2024-12-31]
2
- * Support passing non-reserved validation options to errors
3
-
4
1
  # 7.0.0 [2024-11-30]
5
- * Support Rails v7.x
6
2
  * Removed all method overrides in ActiveModel now that the datetime type correctly stores before_type_cast values.
7
3
 
8
4
  # 6.0.1 [2023-01-12]
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 7.x and ActiveModel.
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', '~> 7.0.0'
34
+ gem 'validates_timeliness', '~> 8.0.0.beta1'
34
35
  ```
35
36
 
36
37
  Run bundler:
@@ -0,0 +1,13 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 8.0.0"
6
+ gem "rspec"
7
+ gem "rspec-rails", "~> 6.0"
8
+ gem "sqlite3", "~> 2.0"
9
+ gem "byebug"
10
+ gem "appraisal"
11
+ gem "nokogiri"
12
+
13
+ gemspec path: "../"
@@ -21,8 +21,6 @@ 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" }
25
-
26
24
  def self.kind
27
25
  :timeliness
28
26
  end
@@ -74,7 +72,7 @@ module ValidatesTimeliness
74
72
  begin
75
73
  restriction_value = @converter.type_cast_value(@converter.evaluate(options[restriction], record))
76
74
  unless value.send(RESTRICTIONS[restriction], restriction_value)
77
- add_error(record, attr_name, restriction, value: value, restriction_value: restriction_value) and break
75
+ add_error(record, attr_name, restriction, restriction_value) and break
78
76
  end
79
77
  rescue => e
80
78
  unless ValidatesTimeliness.ignore_restriction_errors
@@ -85,20 +83,13 @@ module ValidatesTimeliness
85
83
  end
86
84
  end
87
85
 
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)
86
+ def add_error(record, attr_name, message, value=nil)
87
+ value = format_error_value(value) if value
88
+ message_options = { message: options.fetch(:"#{message}_message", options[:message]), restriction: value }
89
+ record.errors.add(attr_name, message, **message_options)
98
90
  end
99
91
 
100
92
  def format_error_value(value)
101
- return unless value
102
93
  format = I18n.t(@type, default: DEFAULT_ERROR_VALUE_FORMATS[@type], scope: 'validates_timeliness.error_value_formats')
103
94
  value.strftime(format)
104
95
  end
@@ -1,3 +1,3 @@
1
1
  module ValidatesTimeliness
2
- VERSION = '7.1.0'
2
+ VERSION = '8.0.0.beta1'
3
3
  end
@@ -185,26 +185,6 @@ 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
-
208
188
  describe "restriction value errors" do
209
189
  let(:person) { Person.new(:birth_date => Date.today) }
210
190
 
@@ -28,6 +28,6 @@ Gem::Specification.new do |s|
28
28
  "wiki_uri" => "#{github_url}/wiki",
29
29
  }
30
30
 
31
- s.add_runtime_dependency("activemodel", [">= 7.0.0", "< 8"])
31
+ s.add_runtime_dependency("activemodel", [">= 8.0.0", "< 9"])
32
32
  s.add_runtime_dependency("timeliness", [">= 0.3.10", "< 1"])
33
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: 7.1.0
4
+ version: 8.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Meehan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-31 00:00:00.000000000 Z
11
+ date: 2024-11-30 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: 7.0.0
19
+ version: 8.0.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '8'
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: 7.0.0
29
+ version: 8.0.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '8'
32
+ version: '9'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: timeliness
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -69,6 +69,7 @@ files:
69
69
  - gemfiles/rails_7_0.gemfile
70
70
  - gemfiles/rails_7_1.gemfile
71
71
  - gemfiles/rails_7_2.gemfile
72
+ - gemfiles/rails_8_0.gemfile
72
73
  - init.rb
73
74
  - lib/generators/validates_timeliness/install_generator.rb
74
75
  - lib/generators/validates_timeliness/templates/en.yml
@@ -127,9 +128,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
127
128
  version: '0'
128
129
  required_rubygems_version: !ruby/object:Gem::Requirement
129
130
  requirements:
130
- - - ">="
131
+ - - ">"
131
132
  - !ruby/object:Gem::Version
132
- version: '0'
133
+ version: 1.3.1
133
134
  requirements: []
134
135
  rubygems_version: 3.4.19
135
136
  signing_key: