date_validator 0.10.0 → 0.12.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 +12 -1
- data/Gemfile +0 -4
- data/Readme.md +1 -1
- data/config/locales/zh-CN.yml +5 -5
- data/date_validator.gemspec +1 -0
- 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 +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0587958367007902f71aaa6c998355ccf98faa62af66f884a1df5b7ee36c9b62'
|
4
|
+
data.tar.gz: 2d51c0d4c8e29bde58cb4b442c49eadf6162b2a1c72a1b7e3d05ccdcd1b4d8ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24782d9c608c4308312e4392e860c09831f0c2a19f114916feb57631722f9a87c79905790c869b1a785e583951b57939c37ab6b6c9d24484d537b2176d46c193
|
7
|
+
data.tar.gz: 2e2bbb1eeba8557913259b678fb5d23f0981bfc2b54f634941d93d667dc6de4c99f3dc2647e11385350df8ccd488efc3987307af7cfc5d078a62fec2a13073e7
|
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/Readme.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# date_validator [![Build Status](https://travis-ci.org/codegram/date_validator.png?branch=master)](https://travis-ci.org/codegram/date_validator)
|
2
2
|
|
3
3
|
|
4
|
-
A simple date validator for Rails. Should be compatible with all latest Rubies (
|
4
|
+
A simple date validator for Rails. Should be compatible with all latest Rubies (>2.2, includes Ruby 3.0).
|
5
5
|
|
6
6
|
|
7
7
|
```shell
|
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}"
|
data/date_validator.gemspec
CHANGED
@@ -8,6 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.authors = ["Oriol Gual", "Josep M. Bach", "Josep Jaume Rey"]
|
9
9
|
s.email = ["info@codegram.com"]
|
10
10
|
s.homepage = "http://github.com/codegram/date_validator"
|
11
|
+
s.license = "MIT"
|
11
12
|
s.summary = %q{A simple, ORM agnostic, Ruby 1.9 compatible date validator for Rails 3+, based on ActiveModel.}
|
12
13
|
s.description = %q{A simple, ORM agnostic, Ruby 1.9 compatible date validator for Rails 3+, based on ActiveModel. Currently supporting :after, :before, :after_or_equal_to and :before_or_equal_to options.}
|
13
14
|
|
@@ -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.12.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-07-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activemodel
|
@@ -123,9 +123,10 @@ files:
|
|
123
123
|
- test/date_validator_test.rb
|
124
124
|
- test/test_helper.rb
|
125
125
|
homepage: http://github.com/codegram/date_validator
|
126
|
-
licenses:
|
126
|
+
licenses:
|
127
|
+
- MIT
|
127
128
|
metadata: {}
|
128
|
-
post_install_message:
|
129
|
+
post_install_message:
|
129
130
|
rdoc_options: []
|
130
131
|
require_paths:
|
131
132
|
- lib
|
@@ -140,8 +141,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
141
|
- !ruby/object:Gem::Version
|
141
142
|
version: '0'
|
142
143
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
144
|
-
signing_key:
|
144
|
+
rubygems_version: 3.2.22
|
145
|
+
signing_key:
|
145
146
|
specification_version: 4
|
146
147
|
summary: A simple, ORM agnostic, Ruby 1.9 compatible date validator for Rails 3+,
|
147
148
|
based on ActiveModel.
|