activemodel-email_address_validator 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +37 -0
- data/CHANGELOG.md +21 -0
- data/Gemfile +2 -1
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/activemodel-email_address_validator.gemspec +10 -11
- data/lib/activemodel_email_address_validator/email_address.rb +4 -4
- data/lib/activemodel_email_address_validator/version.rb +1 -1
- data/test/activemodel-email_address_validator/test_email_address.rb +8 -0
- data/test/minitest_helper.rb +1 -2
- data/test/test_active_model_integration.rb +11 -11
- metadata +8 -8
- data/.travis.yml +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5580fb86ca5fc584177916ac313ca624193f64f06679f441521d5904250d4f2
|
4
|
+
data.tar.gz: ea37fa1181553939391da23a0a4894bc4b98186ca8b5f3b3dcb863c041013478
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f21ef9f11bf4ed601b420dab39bbe62206c47873226e22ee9c3db0597105aa23ffe8064379cd81f34f9367fbcc742689e5303c417bcb6032eeb7d326e3ff9b35
|
7
|
+
data.tar.gz: 4d4e2b281fec06eb2c15a3e5fce997fb67f9c6bb70899bedd5a681c5cc2318a6a89ac68653a239b7735f7a4b18a78bf979f56abcfa1f496a49cc45bc96c37e6a
|
@@ -0,0 +1,37 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ main ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ main ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
strategy:
|
14
|
+
matrix:
|
15
|
+
ruby-version: ['2.4', '2.5', '2.6', '2.7', '3.0', '3.1']
|
16
|
+
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v2
|
19
|
+
- name: Set up Ruby
|
20
|
+
uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: ${{ matrix.ruby-version }}
|
23
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
24
|
+
- name: Run tests
|
25
|
+
run: bundle exec rake
|
26
|
+
|
27
|
+
lint:
|
28
|
+
runs-on: ubuntu-latest
|
29
|
+
steps:
|
30
|
+
- uses: actions/checkout@v2
|
31
|
+
- name: Set up Ruby
|
32
|
+
uses: ruby/setup-ruby@v1
|
33
|
+
with:
|
34
|
+
ruby-version: '3.0'
|
35
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
36
|
+
- name: Lint
|
37
|
+
run: bundle exec standardrb
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,27 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
7
7
|
|
8
|
+
## Unreleased
|
9
|
+
|
10
|
+
### Added
|
11
|
+
|
12
|
+
-
|
13
|
+
|
14
|
+
### Removed
|
15
|
+
|
16
|
+
-
|
17
|
+
|
18
|
+
|
19
|
+
## [2.1.0]
|
20
|
+
|
21
|
+
### Added
|
22
|
+
|
23
|
+
- Support for Ruby 3.0. We've also started testing against Ruby 3.1 to be
|
24
|
+
prepared.
|
25
|
+
|
26
|
+
- Email addresses with trailing @'s are no longer accepted. Thanks
|
27
|
+
@prognostikos!
|
28
|
+
|
8
29
|
## [2.0.0]
|
9
30
|
|
10
31
|
### Added
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Email Address Validator
|
2
2
|
## ActiveModel-style email address format validator
|
3
3
|
|
4
|
-
[![
|
4
|
+
[![Code Climate](https://codeclimate.com/github/substancelab/activemodel-email_address_validator/badges/gpa.svg)](https://codeclimate.com/github/substancelab/activemodel-email_address_validator) [![Coverage Status](https://coveralls.io/repos/substancelab/activemodel-email_address_validator/badge.svg?branch=more-badges&service=github)](https://coveralls.io/github/substancelab/activemodel-email_address_validator?branch=more-badges)
|
5
5
|
|
6
6
|
Whenever I have wanted to validate an email address it has been because I wanted to be somewhat certain I can send an email to someone. Usually this happens as part of a signup procedure.
|
7
7
|
|
data/Rakefile
CHANGED
@@ -1,20 +1,19 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path("../lib", __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require "activemodel_email_address_validator/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
9
|
-
spec.authors
|
10
|
-
spec.email
|
11
|
-
spec.summary
|
12
|
-
spec.homepage
|
13
|
-
spec.license
|
6
|
+
spec.name = "activemodel-email_address_validator"
|
7
|
+
spec.version = ActiveModelEmailAddressValidator::VERSION
|
8
|
+
spec.authors = ["Jakob Skjerning"]
|
9
|
+
spec.email = ["jakob@mentalized.net"]
|
10
|
+
spec.summary = "ActiveModel-style email address format validator"
|
11
|
+
spec.homepage = ""
|
12
|
+
spec.license = "MIT"
|
14
13
|
|
15
|
-
spec.files
|
16
|
-
spec.executables
|
17
|
-
spec.test_files
|
14
|
+
spec.files = `git ls-files -z`.split("\x0")
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
17
|
spec.require_paths = ["lib"]
|
19
18
|
|
20
19
|
spec.add_dependency "activemodel", ">= 4.0", "< 7.0"
|
@@ -25,14 +25,14 @@ module ActiveModelEmailAddressValidator
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def valid_using_default?
|
28
|
-
return false if
|
29
|
-
email_parts = address.split("@")
|
28
|
+
return false if /\s+/.match?(address)
|
29
|
+
email_parts = address.split("@", -1)
|
30
30
|
|
31
31
|
return false unless email_parts.size == 2
|
32
32
|
|
33
33
|
user, host = *email_parts
|
34
|
-
return false unless
|
35
|
-
return false unless
|
34
|
+
return false unless /^([^.]+\S)*[^. ]+$/.match?(user)
|
35
|
+
return false unless /^([^,. ~]+\.)+[^,. ]+$/.match?(host)
|
36
36
|
true
|
37
37
|
end
|
38
38
|
end
|
@@ -101,6 +101,14 @@ class EmailAddressValidTest < MiniTest::Test
|
|
101
101
|
reject("my@nice@domain.com")
|
102
102
|
end
|
103
103
|
|
104
|
+
def test_rejects_leading_at_signs
|
105
|
+
reject("@my@domain.com")
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_rejects_trailing_at_signs
|
109
|
+
reject("my@domain.com@")
|
110
|
+
end
|
111
|
+
|
104
112
|
def test_rejects_commas_in_hostname
|
105
113
|
reject("my@domain.com,")
|
106
114
|
end
|
data/test/minitest_helper.rb
CHANGED
@@ -7,9 +7,8 @@ require "activemodel-email_address_validator"
|
|
7
7
|
require "minitest/autorun"
|
8
8
|
require "minitest/spec"
|
9
9
|
|
10
|
-
SIMPLEST_VALIDATION = {:
|
10
|
+
SIMPLEST_VALIDATION = {email: {email_address: true}}
|
11
11
|
|
12
|
-
# rubocop:disable Metrics/MethodLength
|
13
12
|
def build_model_with_validations(validations = SIMPLEST_VALIDATION)
|
14
13
|
klass = Class.new do
|
15
14
|
include ActiveModel::Validations
|
@@ -8,7 +8,7 @@ class EmailAddressValidatorTest < MiniTest::Test
|
|
8
8
|
|
9
9
|
def test_accepts_nil_email_address
|
10
10
|
@subject = build_model_with_validations(
|
11
|
-
:
|
11
|
+
email: {email_address: true, allow_nil: true}
|
12
12
|
)
|
13
13
|
accept(nil, @subject)
|
14
14
|
end
|
@@ -23,7 +23,7 @@ class EmailAddressValidatorTest < MiniTest::Test
|
|
23
23
|
|
24
24
|
def test_adds_errors_to_validated_attribute
|
25
25
|
subject = build_model_with_validations(
|
26
|
-
:
|
26
|
+
work_email: {email_address: true}
|
27
27
|
)
|
28
28
|
subject.work_email = "whatever"
|
29
29
|
subject.valid?
|
@@ -33,7 +33,7 @@ class EmailAddressValidatorTest < MiniTest::Test
|
|
33
33
|
|
34
34
|
def test_validates_with_custom_regular_expression
|
35
35
|
subject = build_model_with_validations(
|
36
|
-
:
|
36
|
+
email: {email_address: {format: /.+@enterprise\..+/}}
|
37
37
|
)
|
38
38
|
accept("whatever@enterprise.museum", subject)
|
39
39
|
reject("totally@valid.com", subject)
|
@@ -41,7 +41,7 @@ class EmailAddressValidatorTest < MiniTest::Test
|
|
41
41
|
|
42
42
|
def test_validates_with_custom_regular_as_a_rule
|
43
43
|
subject = build_model_with_validations(
|
44
|
-
:
|
44
|
+
email: {email_address: {with: /.+@enterprise\..+/}}
|
45
45
|
)
|
46
46
|
accept("whatever@enterprise.museum", subject)
|
47
47
|
reject("totally@valid.com", subject)
|
@@ -49,9 +49,9 @@ class EmailAddressValidatorTest < MiniTest::Test
|
|
49
49
|
|
50
50
|
def test_validates_with_proc
|
51
51
|
subject = build_model_with_validations(
|
52
|
-
:
|
53
|
-
:
|
54
|
-
}
|
52
|
+
email: {email_address: {
|
53
|
+
with: proc { |address| address == "foo" }
|
54
|
+
}}
|
55
55
|
)
|
56
56
|
accept("foo", subject)
|
57
57
|
reject("foo@bar.com", subject)
|
@@ -59,12 +59,12 @@ class EmailAddressValidatorTest < MiniTest::Test
|
|
59
59
|
|
60
60
|
def test_validates_with_multiple_procs
|
61
61
|
subject = build_model_with_validations(
|
62
|
-
:
|
63
|
-
:
|
62
|
+
email: {email_address: {
|
63
|
+
with: [
|
64
64
|
proc { |address| address == "ada" },
|
65
65
|
proc { |address| address.reverse == address }
|
66
|
-
]
|
67
|
-
}
|
66
|
+
]
|
67
|
+
}}
|
68
68
|
)
|
69
69
|
accept("ada", subject)
|
70
70
|
reject("bob", subject)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemodel-email_address_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakob Skjerning
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -72,15 +72,15 @@ dependencies:
|
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
|
-
description:
|
75
|
+
description:
|
76
76
|
email:
|
77
77
|
- jakob@mentalized.net
|
78
78
|
executables: []
|
79
79
|
extensions: []
|
80
80
|
extra_rdoc_files: []
|
81
81
|
files:
|
82
|
+
- ".github/workflows/ruby.yml"
|
82
83
|
- ".gitignore"
|
83
|
-
- ".travis.yml"
|
84
84
|
- CHANGELOG.md
|
85
85
|
- Gemfile
|
86
86
|
- LICENSE.txt
|
@@ -98,7 +98,7 @@ homepage: ''
|
|
98
98
|
licenses:
|
99
99
|
- MIT
|
100
100
|
metadata: {}
|
101
|
-
post_install_message:
|
101
|
+
post_install_message:
|
102
102
|
rdoc_options: []
|
103
103
|
require_paths:
|
104
104
|
- lib
|
@@ -113,8 +113,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
|
-
rubygems_version: 3.
|
117
|
-
signing_key:
|
116
|
+
rubygems_version: 3.2.32
|
117
|
+
signing_key:
|
118
118
|
specification_version: 4
|
119
119
|
summary: ActiveModel-style email address format validator
|
120
120
|
test_files:
|