emailpms 0.0.1
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 +7 -0
- data/lib/emailpms.rb +27 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1b0bbbb19cc42d2998aef4a6a56f75d76bd7c849
|
4
|
+
data.tar.gz: 384daf0038551103b3f7724cc746a358f2a0a19b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c93ecbe631f9be0a227f9ed25c29d565fbbce3742237adddb2717a2e73a133a6050b040e754b1c7485efc73f321310cc394d2305b1bad59fa7691d669717934d
|
7
|
+
data.tar.gz: f22fb62c3bd2f08969d819ff6542fc6d2d1adfdc906d08a5b849b57976ffacba70c390b82fbca085e108d1f4cfd1e234e259beaee6087d0c26c2a2611a0250af
|
data/lib/emailpms.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
class EmailPms < ActiveModel::EachValidator
|
2
|
+
@@default_options = {}
|
3
|
+
|
4
|
+
def self.regexp(options = {})
|
5
|
+
options = default_options.merge(options)
|
6
|
+
|
7
|
+
name_validation = options[:strict_mode] ? "-\\p{L}\\d+._" : "^@\\s"
|
8
|
+
|
9
|
+
/\A\s*([#{name_validation}]{1,64})@((?:[-\p{L}\d]+\.)+\p{L}{2,})\s*\z/i
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.valid?(value, options = {})
|
13
|
+
!!(value =~ regexp(options))
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.default_options
|
17
|
+
@@default_options
|
18
|
+
end
|
19
|
+
|
20
|
+
def validate_each(record, attribute, value)
|
21
|
+
options = @@default_options.merge(self.options)
|
22
|
+
|
23
|
+
unless self.class.valid?(value, self.options)
|
24
|
+
record.errors.add(attribute, options[:message] || :invalid)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: emailpms
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- finnythomas
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-11-01 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: |-
|
14
|
+
returns true if the given email is correct,
|
15
|
+
otherwise returns alert.
|
16
|
+
email: finnytho93@email.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/emailpms.rb
|
22
|
+
homepage: http://rubygems.org/gems/isNumberEven
|
23
|
+
licenses: []
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.5.1
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: verifies if a given email is true.
|
45
|
+
test_files: []
|