valid_email2 5.0.5 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/valid_email2/email_validator.rb +3 -1
- data/lib/valid_email2/version.rb +1 -1
- data/spec/valid_email2_spec.rb +33 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca51b0f797d9251b8a850e2d55640ea0c278128f29ebed57b8d1e0d426393b0f
|
4
|
+
data.tar.gz: e3d180928ccea8db43191a40df53c0b2f8a226452b30fa55e8ed3d4a32c39186
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0cdb4311843b16ee38ab13c774c8f9f4e75c6e208f2feca5e143d8abf465bfb29d0e6bf314e0789d18178620bac7c96c17c06fb61c5d4a32b5157ac8a584cf4
|
7
|
+
data.tar.gz: 3c8fc7f7ae71dcb32f290254678d98f1d15151c60ee15602d82765947faae76466609ac483c910f8ce0a3f403eaaab8126abf001b00311c2556ae58d40bbcb66
|
data/CHANGELOG.md
CHANGED
@@ -66,7 +66,9 @@ module ValidEmail2
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def error(record, attribute)
|
69
|
-
|
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
|
data/lib/valid_email2/version.rb
CHANGED
data/spec/valid_email2_spec.rb
CHANGED
@@ -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
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
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
|
+
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-
|
11
|
+
date: 2023-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|