valid_email 0.0.12 → 0.0.13

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
  SHA1:
3
- metadata.gz: c545251c17d33f29c1cc777e798aa7a08937af43
4
- data.tar.gz: 78da306fab1e3a75633be0cb25c7430d809e0361
3
+ metadata.gz: ca6b2a7baefd0f49bd9f7bceb9bdcc809164fd2b
4
+ data.tar.gz: 0a66612b626c0e168b2f18e419cf8ca42c554370
5
5
  SHA512:
6
- metadata.gz: 48566bddaff58f5d006f3b398a39ca3713902805eec7ef69fcc9fe0b6a7451aaf40fc457627e568a973336559a171c6ad2f98732e1806e9cc88e943334000d68
7
- data.tar.gz: 41fd65d81b424fbbbb566f8f94e9be28f435afeca997fe49f4409508b76136a1fab068100181adb0e0998d1a0fd99ee199f76c9a07f9936fdaac95377a1128d9
6
+ metadata.gz: e462c60e4c9e72b373a6a17132b29c17d08589c40f32a261690395aae79dafb96072ad40b4b30904632498906a6003ee1acb0ce75417f019e5d4541333d24bc1
7
+ data.tar.gz: fcb9dc08ef5995b1b2c69b55b4224001f47ba09995adf206a3c1a53fad0e25ebf501b3923754f04ec97d5e0a636a3011dde80ae45275bd2d2a89bd216881ada8
@@ -0,0 +1,5 @@
1
+ id:
2
+ valid_email:
3
+ validations:
4
+ email:
5
+ invalid: "tidak valid"
@@ -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
@@ -1 +1 @@
1
- ValidEmailVersion = "0.0.12"
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
@@ -1,2 +1,6 @@
1
1
  $:.unshift File.expand_path('../../lib',__FILE__)
2
2
  require 'valid_email'
3
+
4
+ RSpec.configure do |config|
5
+ config.raise_errors_for_deprecations!
6
+ end
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.12
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-01-23 00:00:00.000000000 Z
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