date_validator 0.10.0 → 0.11.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 +12 -1
- data/Gemfile +0 -4
- data/config/locales/zh-CN.yml +5 -5
- data/lib/active_model/validations/date_validator.rb +4 -4
- data/lib/date_validator/version.rb +1 -1
- data/test/date_validator_test.rb +2 -0
- data/test/test_helper.rb +1 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '089b8331eec9d9832d3867d22d213f0fe9f16f1c0e61982def3e19b171dc729d'
|
4
|
+
data.tar.gz: f2e3b93ed21294cef464284976e2edcc2fab27bb0bf6b37b18a494b241dd85d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bef6a2179671eb18059b1fc21c5796d11a425803a0041371e5f456c5a5b244e8aa3266fe89be416c5acf527ea40dd15a183090e75cd8cb8ab9b4f73c5ca60a96
|
7
|
+
data.tar.gz: a98af5f8076fbfc0dc3e83b3dbf8e5df23330638a2048a3a6804e3e3b05c49b62bc1a77cfab04e715b2d19a34f122b66aea570976cadc0629505fec00f45a62a
|
data/.github/workflows/ci.yml
CHANGED
@@ -18,7 +18,12 @@ jobs:
|
|
18
18
|
strategy:
|
19
19
|
matrix:
|
20
20
|
ruby: [2.2, 2.3, 2.4, 2.5, 2.6, 2.7]
|
21
|
-
activemodel: [3.2, 4.0, 4.1, 4.2, 5.0, 5.1, 5.2, 6.0]
|
21
|
+
activemodel: [3.2, 4.0, 4.1, 4.2, 5.0, 5.1, 5.2, 6.0, 6.1]
|
22
|
+
include:
|
23
|
+
- ruby: 3.0
|
24
|
+
activemodel: 6.0
|
25
|
+
- ruby: 3.0
|
26
|
+
activemodel: 6.1
|
22
27
|
exclude:
|
23
28
|
- ruby: 2.2
|
24
29
|
activemodel: 6.0
|
@@ -26,6 +31,12 @@ jobs:
|
|
26
31
|
activemodel: 6.0
|
27
32
|
- ruby: 2.4
|
28
33
|
activemodel: 6.0
|
34
|
+
- ruby: 2.2
|
35
|
+
activemodel: 6.1
|
36
|
+
- ruby: 2.3
|
37
|
+
activemodel: 6.1
|
38
|
+
- ruby: 2.4
|
39
|
+
activemodel: 6.1
|
29
40
|
fail-fast: true
|
30
41
|
env:
|
31
42
|
ACTIVE_MODEL_VERSION: ${{ matrix.activemodel }}
|
data/Gemfile
CHANGED
data/config/locales/zh-CN.yml
CHANGED
@@ -2,8 +2,8 @@ zh-CN:
|
|
2
2
|
errors:
|
3
3
|
messages:
|
4
4
|
not_a_date: "不是一个日期"
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
date_after: "必须晚于 %{date}"
|
6
|
+
date_after_or_equal_to: "必须早于或等于 %{date}"
|
7
|
+
date_before: "必须早于 %{date}"
|
8
|
+
date_before_or_equal_to: "必须晚于或等于 %{date}"
|
9
|
+
date_equal_to: "必须等于 %{date}"
|
@@ -59,19 +59,19 @@ module ActiveModel
|
|
59
59
|
end
|
60
60
|
|
61
61
|
if value_before_type_cast.present? && value.nil?
|
62
|
-
record.errors.add(attr_name, :not_a_date, options)
|
62
|
+
record.errors.add(attr_name, :not_a_date, **options)
|
63
63
|
return
|
64
64
|
end
|
65
65
|
|
66
66
|
return if (value.nil? && options[:allow_nil]) || (value.blank? && options[:allow_blank])
|
67
67
|
|
68
68
|
unless value
|
69
|
-
record.errors.add(attr_name, :not_a_date, options)
|
69
|
+
record.errors.add(attr_name, :not_a_date, **options)
|
70
70
|
return
|
71
71
|
end
|
72
72
|
|
73
73
|
unless is_time?(value)
|
74
|
-
record.errors.add(attr_name, :not_a_date, options)
|
74
|
+
record.errors.add(attr_name, :not_a_date, **options)
|
75
75
|
return
|
76
76
|
end
|
77
77
|
|
@@ -94,7 +94,7 @@ module ActiveModel
|
|
94
94
|
end
|
95
95
|
|
96
96
|
unless is_time?(option_value) && value.to_i.send(CHECKS[option], option_value.to_i)
|
97
|
-
record.errors.add(attr_name, :"date_#{option}", options.merge(
|
97
|
+
record.errors.add(attr_name, :"date_#{option}", **options.merge(
|
98
98
|
value: original_value,
|
99
99
|
date: (I18n.localize(original_option_value) rescue original_option_value)
|
100
100
|
))
|
data/test/date_validator_test.rb
CHANGED
@@ -84,6 +84,8 @@ module ActiveModel
|
|
84
84
|
|
85
85
|
it "allows custom validation message to be handled by I18n" do
|
86
86
|
custom_message = 'Custom Date Message'
|
87
|
+
|
88
|
+
I18n.backend.eager_load! if I18n.backend.respond_to?(:eager_load!)
|
87
89
|
I18n.backend.store_translations('en', { errors: { messages: { not_a_date: custom_message }}})
|
88
90
|
|
89
91
|
TestRecord.validates :expiration_date, date: true
|
data/test/test_helper.rb
CHANGED
@@ -12,6 +12,7 @@ gem 'minitest'
|
|
12
12
|
require 'minitest/autorun'
|
13
13
|
|
14
14
|
require 'active_model'
|
15
|
+
require 'active_support/core_ext/time/zones'
|
15
16
|
require 'date_validator'
|
16
17
|
|
17
18
|
I18n.load_path += Dir[File.expand_path(File.join(File.dirname(__FILE__), '../config/locales', '*.yml')).to_s]
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: date_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oriol Gual
|
8
8
|
- Josep M. Bach
|
9
9
|
- Josep Jaume Rey
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-05-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activemodel
|
@@ -125,7 +125,7 @@ files:
|
|
125
125
|
homepage: http://github.com/codegram/date_validator
|
126
126
|
licenses: []
|
127
127
|
metadata: {}
|
128
|
-
post_install_message:
|
128
|
+
post_install_message:
|
129
129
|
rdoc_options: []
|
130
130
|
require_paths:
|
131
131
|
- lib
|
@@ -140,8 +140,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0'
|
142
142
|
requirements: []
|
143
|
-
rubygems_version: 3.1.
|
144
|
-
signing_key:
|
143
|
+
rubygems_version: 3.1.4
|
144
|
+
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: A simple, ORM agnostic, Ruby 1.9 compatible date validator for Rails 3+,
|
147
147
|
based on ActiveModel.
|