valid_email2 5.0.4 → 5.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb0c608a5b413d559c4458934aaeea9def9d9172c60331e0e8c105423bc6c621
4
- data.tar.gz: d16b5cd998cd2223a51931a3552068e7f5cbc6bcce0e5946c4f848d9d2b53e4f
3
+ metadata.gz: ca51b0f797d9251b8a850e2d55640ea0c278128f29ebed57b8d1e0d426393b0f
4
+ data.tar.gz: e3d180928ccea8db43191a40df53c0b2f8a226452b30fa55e8ed3d4a32c39186
5
5
  SHA512:
6
- metadata.gz: 7a3629ba5e3ab86b8a327c076145ad9d64325f669076da2dcc69433a5e598bd8cfaa67b5903da96f839f4cb63e5917ce8ee1f144b316b62d2ec3ef6c376ceb25
7
- data.tar.gz: e199405c917b6963fc371fa9b5ffb30c08818ec911d6a6e5bcce4be1f1529c462240a48e9805bc9ce17326b363494be80f4d18600262b4bede94d82106b9d6a7
6
+ metadata.gz: b0cdb4311843b16ee38ab13c774c8f9f4e75c6e208f2feca5e143d8abf465bfb29d0e6bf314e0789d18178620bac7c96c17c06fb61c5d4a32b5157ac8a584cf4
7
+ data.tar.gz: 3c8fc7f7ae71dcb32f290254678d98f1d15151c60ee15602d82765947faae76466609ac483c910f8ce0a3f403eaaab8126abf001b00311c2556ae58d40bbcb66
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
+ ## Version 5.1.0
2
+ * Allow dynamic validaton error messages [#221](https://github.com/micke/valid_email2/pull/221)
3
+
4
+ ## Version 5.0.5
5
+ * Remove false positive duck.com
6
+
1
7
  ## Version 5.0.4
2
- * Remove false positives
8
+ * Remove false positives:
9
+ * https://github.com/micke/valid_email2/pull/212
10
+ * https://github.com/micke/valid_email2/pull/213
11
+ * https://github.com/micke/valid_email2/pull/215
3
12
 
4
13
  ## Version 5.0.3
5
14
  * Remove false positive mail.com [#210](https://github.com/micke/valid_email2/issues/210)
@@ -46278,7 +46278,6 @@ dubukim.me
46278
46278
  dubzone.com
46279
46279
  ducatimotorclubdenver.com
46280
46280
  duck.9amail.top
46281
- duck.com
46282
46281
  duck2.club
46283
46282
  duckbao.com
46284
46283
  duckcover.com
@@ -66,7 +66,9 @@ module ValidEmail2
66
66
  end
67
67
 
68
68
  def error(record, attribute)
69
- record.errors.add(attribute, options[:message] || :invalid)
69
+ message = options[:message].respond_to?(:call) ? options[:message].call : options[:message]
70
+
71
+ record.errors.add(attribute, message || :invalid)
70
72
  end
71
73
  end
72
74
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal:true
2
2
 
3
3
  module ValidEmail2
4
- VERSION = "5.0.4"
4
+ VERSION = "5.1.0"
5
5
  end
@@ -10,7 +10,10 @@ whitelisted_emails = %w(
10
10
  hush.ai hush.com hushmail.me naver.com qq.com example.com
11
11
  yandex.net gmx.com gmx.es webdesignspecialist.com.au vp.com
12
12
  onit.com asics.com freemail.hu 139.com mail2world.com slmail.me
13
- zoho.com zoho.in
13
+ zoho.com zoho.in simplelogin.com simplelogin.fr simplelogin.co
14
+ simplelogin.io aleeas.com slmails.com silomails.com slmail.me
15
+ passinbox.com passfwd.com passmail.com passmail.net
16
+ duck.com mozmail.com
14
17
  )
15
18
 
16
19
  existing_emails = File.open("config/disposable_email_domains.txt") { |f| f.read.split("\n") }
@@ -47,6 +47,14 @@ class TestUserMessage < TestModel
47
47
  validates :email, 'valid_email_2/email': { message: "custom message" }
48
48
  end
49
49
 
50
+ class TestUserMessageWithLambda < TestModel
51
+ validates :email, 'valid_email_2/email': { message: -> { "custom message lambda" } }
52
+ end
53
+
54
+ class TestUserMessageWithProc < TestModel
55
+ validates :email, 'valid_email_2/email': { message: Proc.new { "custom message proc" } }
56
+ end
57
+
50
58
  class TestUserMultiple < TestModel
51
59
  validates :email, 'valid_email_2/email': { multiple: true }
52
60
  end
@@ -188,11 +196,11 @@ describe ValidEmail2 do
188
196
  let(:whitelist_domain) { disposable_domain }
189
197
  let(:whitelist_file_path) { "config/whitelisted_email_domains.yml" }
190
198
 
191
- # Some of the specs below need to explictly set the whitelist var or it
199
+ # Some of the specs below need to explictly set the whitelist var or it
192
200
  # may be cached to an empty set
193
201
  def set_whitelist
194
202
  ValidEmail2.instance_variable_set(
195
- :@whitelist,
203
+ :@whitelist,
196
204
  ValidEmail2.send(:load_if_exists, ValidEmail2::WHITELIST_FILE)
197
205
  )
198
206
  end
@@ -308,11 +316,29 @@ describe ValidEmail2 do
308
316
  end
309
317
  end
310
318
 
311
- describe "with custom error message" do
312
- it "supports settings a custom error message" do
313
- user = TestUserMessage.new(email: "fakeemail")
314
- user.valid?
315
- expect(user.errors.full_messages).to include("Email custom message")
319
+ context "when message is present" do
320
+ describe "with custom error message" do
321
+ it "supports settings a custom error message" do
322
+ user = TestUserMessage.new(email: "fakeemail")
323
+ user.valid?
324
+ expect(user.errors.full_messages).to include("Email custom message")
325
+ end
326
+ end
327
+
328
+ describe "with custom error message lambda" do
329
+ it "supports settings a custom error message lambda" do
330
+ user = TestUserMessageWithLambda.new(email: "fakeemail")
331
+ user.valid?
332
+ expect(user.errors.full_messages).to include("Email custom message lambda")
333
+ end
334
+ end
335
+
336
+ describe "with custom error message proc" do
337
+ it "supports settings a custom error message proc" do
338
+ user = TestUserMessageWithProc.new(email: "fakeemail")
339
+ user.valid?
340
+ expect(user.errors.full_messages).to include("Email custom message proc")
341
+ end
316
342
  end
317
343
  end
318
344
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valid_email2
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.4
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micke Lisinge
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-29 00:00:00.000000000 Z
11
+ date: 2023-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler