valid_email 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/locales/id.yml +5 -0
- data/lib/valid_email/email_validator.rb +4 -4
- data/lib/valid_email/version.rb +1 -1
- data/spec/email_validator_spec.rb +15 -2
- data/spec/spec_helper.rb +4 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca6b2a7baefd0f49bd9f7bceb9bdcc809164fd2b
|
4
|
+
data.tar.gz: 0a66612b626c0e168b2f18e419cf8ca42c554370
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e462c60e4c9e72b373a6a17132b29c17d08589c40f32a261690395aae79dafb96072ad40b4b30904632498906a6003ee1acb0ce75417f019e5d4541333d24bc1
|
7
|
+
data.tar.gz: fcb9dc08ef5995b1b2c69b55b4224001f47ba09995adf206a3c1a53fad0e25ebf501b3923754f04ec97d5e0a636a3011dde80ae45275bd2d2a89bd216881ada8
|
@@ -10,19 +10,19 @@ class EmailValidator < ActiveModel::EachValidator
|
|
10
10
|
# Check if domain has DNS MX record
|
11
11
|
if r && options[:mx]
|
12
12
|
require 'valid_email/mx_validator'
|
13
|
-
r = MxValidator.new(:attributes => attributes).validate(record)
|
13
|
+
r = MxValidator.new(:attributes => attributes, message: options[:message]).validate(record)
|
14
14
|
elsif r && options[:mx_with_fallback]
|
15
15
|
require 'valid_email/mx_with_fallback_validator'
|
16
|
-
r = MxWithFallbackValidator.new(:attributes => attributes).validate(record)
|
16
|
+
r = MxWithFallbackValidator.new(:attributes => attributes, message: options[:message]).validate(record)
|
17
17
|
end
|
18
18
|
# Check if domain is disposable
|
19
19
|
if r && options[:ban_disposable_email]
|
20
20
|
require 'valid_email/ban_disposable_email_validator'
|
21
|
-
r = BanDisposableEmailValidator.new(:attributes => attributes).validate(record)
|
21
|
+
r = BanDisposableEmailValidator.new(:attributes => attributes, message: options[:message]).validate(record)
|
22
22
|
end
|
23
23
|
unless r
|
24
24
|
msg = (options[:message] || I18n.t(:invalid, :scope => "valid_email.validations.email"))
|
25
25
|
record.errors.add attribute, (msg % {value: value})
|
26
|
-
end
|
26
|
+
end
|
27
27
|
end
|
28
28
|
end
|
data/lib/valid_email/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ValidEmailVersion = "0.0.
|
1
|
+
ValidEmailVersion = "0.0.13"
|
@@ -55,6 +55,12 @@ describe EmailValidator do
|
|
55
55
|
validates :email, :domain => true
|
56
56
|
end
|
57
57
|
|
58
|
+
person_message_specified = Class.new do
|
59
|
+
include ActiveModel::Validations
|
60
|
+
attr_accessor :email
|
61
|
+
validates :email, :email => { :message => 'custom message', :ban_disposable_email => true }
|
62
|
+
end
|
63
|
+
|
58
64
|
shared_examples_for "Invalid model" do
|
59
65
|
before { subject.valid? }
|
60
66
|
|
@@ -239,7 +245,6 @@ describe EmailValidator do
|
|
239
245
|
expect(subject).to be_valid
|
240
246
|
expect(subject.errors[:email]).to be_empty
|
241
247
|
end
|
242
|
-
|
243
248
|
end
|
244
249
|
|
245
250
|
describe "Can allow blank" do
|
@@ -250,7 +255,16 @@ describe EmailValidator do
|
|
250
255
|
expect(subject).to be_valid
|
251
256
|
expect(subject.errors[:email]).to be_empty
|
252
257
|
end
|
258
|
+
end
|
259
|
+
|
260
|
+
describe "Accepts custom messages" do
|
261
|
+
subject { person_message_specified.new }
|
253
262
|
|
263
|
+
it "adds only the custom error" do
|
264
|
+
subject.email = 'bad@mailnator.com'
|
265
|
+
expect(subject.valid?).to be_falsey
|
266
|
+
expect(subject.errors[:email]).to match_array [ 'custom message' ]
|
267
|
+
end
|
254
268
|
end
|
255
269
|
|
256
270
|
describe "Translating in english" do
|
@@ -261,7 +275,6 @@ describe EmailValidator do
|
|
261
275
|
|
262
276
|
describe "Translating in french" do
|
263
277
|
let!(:locale){ :fr }
|
264
|
-
|
265
278
|
let!(:errors) { [ "est invalide" ] }
|
266
279
|
it_behaves_like "Validating emails"
|
267
280
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: valid_email
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ramihajamalala Hery
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- config/locales/fi.yml
|
85
85
|
- config/locales/fr.yml
|
86
86
|
- config/locales/hu.yml
|
87
|
+
- config/locales/id.yml
|
87
88
|
- config/locales/ja.yml
|
88
89
|
- config/locales/pl.yml
|
89
90
|
- config/locales/ru.yml
|