mail_validation 0.0.1 → 0.0.2

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: c64e9807e9cb32624b7ee2fe0ba5956eea0d56b5
4
- data.tar.gz: 4483d06d285e24b53747c747fd342c60358792f6
3
+ metadata.gz: 011cff547dd9e860de9cc3f545e89842e5fcb4a9
4
+ data.tar.gz: a3a39f1f37bd7908911752cc09ce8a9479937ee6
5
5
  SHA512:
6
- metadata.gz: 8366d7be95c58ba7baf114eade401d11203bb17054c40e9c25535ba43a8c2d4939877cd5faad43a293a99869162f1292576eacb8b2fea26b2045c19b09ae0f0d
7
- data.tar.gz: 9d5d78833b9ee4d015390075ac77bf0dbfcc6a7fe719295156582273e4cde636d948048910559c34779174d3ce2c2b3bc24a3c5f8ff68224168fcc5ea1e802f5
6
+ metadata.gz: 60e323e4ce6bddba0f3d697633df2bea0eafa1cd95e7a686d0315fb1766bc5c717556ab71e9311c53fbc389a93f6a340675597144711e045a1930e1052da4125
7
+ data.tar.gz: 877530775c201f0ddbf5b4abe8d2cf162c9a8716764ebe4c496522e73c9386c0f8e856594de751f1a8fc4e07e66089d772effab2af9de1ef480c9f10d65f9caf
@@ -5,7 +5,7 @@ module MailValidation
5
5
  def validate_each(record, attribute, value)
6
6
  begin
7
7
  address = Mail::Address.new(value)
8
- if address.domain.nil?
8
+ if address.domain.nil? || !address.domain.match(/\.[A-Za-z]+\z/)
9
9
  append_error(record, attribute)
10
10
  end
11
11
  rescue Mail::Field::ParseError => e
@@ -1,3 +1,3 @@
1
1
  module MailValidation
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -22,6 +22,14 @@ describe MailValidation::EmailValidator do
22
22
  expect(user).to_not be_valid
23
23
  end
24
24
 
25
+ it 'adds an error if the email does not have a TLD' do
26
+ user = User.new.tap do |u|
27
+ u.email = 'bademail@example'
28
+ end
29
+
30
+ expect(user).to_not be_valid
31
+ end
32
+
25
33
  it 'adds an error if the email is invalid' do
26
34
  user = User.new.tap do |u|
27
35
  u.email = '@.com'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mail_validation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Pickett