email_valid8 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/email_valid8.rb +29 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5856aeca30b3821f1b1a47b74c0ac1061d90cbf46f8031c4361a297a1107092b
|
4
|
+
data.tar.gz: 0fd2f80068a7fc1d5283962517220c4513133ac2587890c5eeca6a0091c6b0f1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 73efab447a2042899de9abd71fcc5cd7127333054275b3d6b00fae45a05403c6dc86d8b385f4df5025fb1aefd199fad6b3c9a4e9b1cfa13f9e5846896ea6a2bf
|
7
|
+
data.tar.gz: d81e25c638b6b86118030b5aa0b9d3af20d8dc72d2941ac2552a9833dde74f806ce68a94db35c14b47862f639bb4fc050fbdc37891e44c3241c265b63706b256
|
data/lib/email_valid8.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'active_model'
|
2
|
+
|
3
|
+
class EmailAddressValidator < ActiveModel::Validator
|
4
|
+
def validate(record)
|
5
|
+
return if record.blank?
|
6
|
+
|
7
|
+
fields = options[:fields]
|
8
|
+
multiples = options[:multiples]
|
9
|
+
|
10
|
+
fields.each do |field|
|
11
|
+
next if record.send(field).blank?
|
12
|
+
|
13
|
+
attrs = record.send(field)
|
14
|
+
if multiples
|
15
|
+
attrs.split(',').each do |attr|
|
16
|
+
attr.class == Array ? attr.each { |email| check_email(email, field, record) } : check_email(attr.strip, field, record)
|
17
|
+
end
|
18
|
+
else
|
19
|
+
check_email(attrs, field, record)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def check_email(email, field, record)
|
25
|
+
return if email =~ URI::MailTo::EMAIL_REGEXP && email !~ /[A-Z]/
|
26
|
+
|
27
|
+
record.errors.add(field, 'is not written in a valid format')
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: email_valid8
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Boyd
|
8
|
+
- Gary Foster
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2019-07-16 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activemodel
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: faker
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rspec
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.7'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.7'
|
70
|
+
description: |-
|
71
|
+
This validator uses modern email validation with URI to handle the nuances of checking email \
|
72
|
+
throughout your application. Rather than customizing a bunch of random regex that you found \
|
73
|
+
on various stack overflow pages, this lets you include a single validator throughout your \
|
74
|
+
entire application. It can handle single emails, or even the odd case of multiple emails in a long \
|
75
|
+
string.
|
76
|
+
email: mikeallenboyd@gmail.com
|
77
|
+
executables: []
|
78
|
+
extensions: []
|
79
|
+
extra_rdoc_files: []
|
80
|
+
files:
|
81
|
+
- lib/email_valid8.rb
|
82
|
+
homepage: https://github.com/ohboyd/email_valid8
|
83
|
+
licenses:
|
84
|
+
- MIT
|
85
|
+
metadata: {}
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 2.7.7
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: Easy mix-in for consistent email validation using built-in Ruby library.
|
106
|
+
test_files: []
|