date_validator 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88a10cd8606bfd0b406c79deacb8e99394f4e1fc5781391560b5413b59a40357
4
- data.tar.gz: 8b4f1033a4ec532e0f1cfb9ff36143d71a96b87578a4a5310b8858f7a5073c57
3
+ metadata.gz: '089b8331eec9d9832d3867d22d213f0fe9f16f1c0e61982def3e19b171dc729d'
4
+ data.tar.gz: f2e3b93ed21294cef464284976e2edcc2fab27bb0bf6b37b18a494b241dd85d0
5
5
  SHA512:
6
- metadata.gz: 98c6d6d166a0a74b23f698c2b67a4c7cb037b110742b537f59f71a4e99e0b089136e8eb110fe785b852e3696820f562e2848a1af930a2fcdec9cf695b3a606d7
7
- data.tar.gz: a72d2efdf1f7fc0578fd3482a174f1369afc280ced7a5f86f3559b2696d65fa47910e9fa8418005274c3a47763b5ddc69363939211016a53e6b3f0e4c8800c18
6
+ metadata.gz: bef6a2179671eb18059b1fc21c5796d11a425803a0041371e5f456c5a5b244e8aa3266fe89be416c5acf527ea40dd15a183090e75cd8cb8ab9b4f73c5ca60a96
7
+ data.tar.gz: a98af5f8076fbfc0dc3e83b3dbf8e5df23330638a2048a3a6804e3e3b05c49b62bc1a77cfab04e715b2d19a34f122b66aea570976cadc0629505fec00f45a62a
@@ -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
@@ -10,7 +10,3 @@ active_model_opts =
10
10
  end
11
11
 
12
12
  gem 'activemodel', active_model_opts
13
-
14
- platforms :rbx do
15
- gem 'rubysl', '~> 2.0'
16
- end
@@ -2,8 +2,8 @@ zh-CN:
2
2
  errors:
3
3
  messages:
4
4
  not_a_date: "不是一个日期"
5
- after: "必须晚于 %{date}"
6
- after_or_equal_to: "必须早于或等于 %{date}"
7
- before: "必须早于 %{date}"
8
- before_or_equal_to: "必须晚于或等于 %{date}"
9
- equal_to: "必须等于 %{date}"
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
  ))
@@ -1,4 +1,4 @@
1
1
  module DateValidator
2
2
  # The version number.
3
- VERSION = "0.10.0"
3
+ VERSION = "0.11.0"
4
4
  end
@@ -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.10.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: 2020-04-03 00:00:00.000000000 Z
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.2
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.