email_validation 1.0.0
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.
- data/.document +5 -0
- data/.gitignore +25 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +41 -0
- data/LICENSE +20 -0
- data/README.textile +39 -0
- data/Rakefile +30 -0
- data/VERSION +1 -0
- data/email_validation.gemspec +50 -0
- data/lib/email_validation.rb +20 -0
- metadata +89 -0
data/.document
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
## MAC OS
|
2
|
+
.DS_Store
|
3
|
+
|
4
|
+
## TEXTMATE
|
5
|
+
*.tmproj
|
6
|
+
tmtags
|
7
|
+
|
8
|
+
## EMACS
|
9
|
+
*~
|
10
|
+
\#*
|
11
|
+
.\#*
|
12
|
+
|
13
|
+
## VIM
|
14
|
+
*.swp
|
15
|
+
|
16
|
+
## PROJECT::GENERAL
|
17
|
+
coverage
|
18
|
+
rdoc
|
19
|
+
pkg
|
20
|
+
.bundle
|
21
|
+
.rvmrc
|
22
|
+
|
23
|
+
## PROJECT::DOCUMENTATION
|
24
|
+
.yardoc
|
25
|
+
doc
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
RedCloth (4.2.3)
|
5
|
+
activemodel (3.0.1)
|
6
|
+
activesupport (= 3.0.1)
|
7
|
+
builder (~> 2.1.2)
|
8
|
+
i18n (~> 0.4.1)
|
9
|
+
activerecord (3.0.1)
|
10
|
+
activemodel (= 3.0.1)
|
11
|
+
activesupport (= 3.0.1)
|
12
|
+
arel (~> 1.0.0)
|
13
|
+
tzinfo (~> 0.3.23)
|
14
|
+
activesupport (3.0.1)
|
15
|
+
arel (1.0.1)
|
16
|
+
activesupport (~> 3.0.0)
|
17
|
+
builder (2.1.2)
|
18
|
+
gemcutter (0.6.1)
|
19
|
+
git (1.2.5)
|
20
|
+
i18n (0.4.2)
|
21
|
+
jeweler (1.4.0)
|
22
|
+
gemcutter (>= 0.1.0)
|
23
|
+
git (>= 1.2.5)
|
24
|
+
rubyforge (>= 2.0.0)
|
25
|
+
json_pure (1.4.6)
|
26
|
+
localized_each_validator (1.0.1)
|
27
|
+
activerecord (>= 3.0)
|
28
|
+
activesupport (>= 3.0)
|
29
|
+
rubyforge (2.0.4)
|
30
|
+
json_pure (>= 1.1.7)
|
31
|
+
tzinfo (0.3.23)
|
32
|
+
yard (0.6.1)
|
33
|
+
|
34
|
+
PLATFORMS
|
35
|
+
ruby
|
36
|
+
|
37
|
+
DEPENDENCIES
|
38
|
+
RedCloth
|
39
|
+
jeweler
|
40
|
+
localized_each_validator (>= 1.0.1)
|
41
|
+
yard
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Tim Morgan
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
h1. email_validation -- Simple email validator for Rails 3
|
2
|
+
|
3
|
+
| *Author* | Tim Morgan |
|
4
|
+
| *Version* | 1.0 (Oct 30, 2010) |
|
5
|
+
| *License* | Released under the MIT license. |
|
6
|
+
|
7
|
+
h2. About
|
8
|
+
|
9
|
+
This gem adds a very simple email address format validator to be used with ActiveRecord models in Rails 3.0. It supports localized error messages.
|
10
|
+
|
11
|
+
h2. Installation
|
12
|
+
|
13
|
+
Add the gem to your project's @Gemfile@:
|
14
|
+
|
15
|
+
<pre><code>
|
16
|
+
gem 'email_validation'
|
17
|
+
</code></pre>
|
18
|
+
|
19
|
+
h2. Usage
|
20
|
+
|
21
|
+
This gem is an @EachValidator@, and thus is used with the @validates@ method:
|
22
|
+
|
23
|
+
<pre><code>
|
24
|
+
class User < ActiveRecord::Base
|
25
|
+
validates :email_address,
|
26
|
+
presence: true,
|
27
|
+
email: true
|
28
|
+
end
|
29
|
+
</code></pre>
|
30
|
+
|
31
|
+
The localization key is @invalid_email@, and can be specified in the localized YAML file like so:
|
32
|
+
|
33
|
+
<pre><code>
|
34
|
+
en:
|
35
|
+
activerecord:
|
36
|
+
errors:
|
37
|
+
messages:
|
38
|
+
invalid_email: Email address is invalid.
|
39
|
+
</code></pre>
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rake'
|
2
|
+
begin
|
3
|
+
require 'bundler'
|
4
|
+
rescue LoadError
|
5
|
+
puts "Bundler is not installed; install with `gem install bundler`."
|
6
|
+
exit 1
|
7
|
+
end
|
8
|
+
|
9
|
+
Bundler.require :default
|
10
|
+
|
11
|
+
Jeweler::Tasks.new do |gem|
|
12
|
+
gem.name = "email_validation"
|
13
|
+
gem.summary = %Q{Simple email validation in Rails 3}
|
14
|
+
gem.description = %Q{A simple, localizable EachValidator for email address fields in ActiveRecord 3.0.}
|
15
|
+
gem.email = "git@timothymorgan.info"
|
16
|
+
gem.homepage = "http://github.com/riscfuture/email_validation"
|
17
|
+
gem.authors = [ "Tim Morgan" ]
|
18
|
+
gem.add_dependency 'localized_each_validator', '>= 1.0.1'
|
19
|
+
end
|
20
|
+
Jeweler::GemcutterTasks.new
|
21
|
+
|
22
|
+
YARD::Rake::YardocTask.new('doc') do |doc|
|
23
|
+
doc.options << "-m" << "textile"
|
24
|
+
doc.options << "--protected"
|
25
|
+
doc.options << "-r" << "README.textile"
|
26
|
+
doc.options << "-o" << "doc"
|
27
|
+
doc.options << "--title" << "email_validation Documentation".inspect
|
28
|
+
|
29
|
+
doc.files = [ 'lib/*_validator.rb', 'README.textile' ]
|
30
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{email_validation}
|
8
|
+
s.version = "1.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Tim Morgan"]
|
12
|
+
s.date = %q{2010-10-31}
|
13
|
+
s.description = %q{A simple, localizable EachValidator for email address fields in ActiveRecord 3.0.}
|
14
|
+
s.email = %q{git@timothymorgan.info}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.textile"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE",
|
25
|
+
"README.textile",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"email_validation.gemspec",
|
29
|
+
"lib/email_validation.rb"
|
30
|
+
]
|
31
|
+
s.homepage = %q{http://github.com/riscfuture/email_validation}
|
32
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
33
|
+
s.require_paths = ["lib"]
|
34
|
+
s.rubygems_version = %q{1.3.7}
|
35
|
+
s.summary = %q{Simple email validation in Rails 3}
|
36
|
+
|
37
|
+
if s.respond_to? :specification_version then
|
38
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
39
|
+
s.specification_version = 3
|
40
|
+
|
41
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
42
|
+
s.add_runtime_dependency(%q<localized_each_validator>, [">= 1.0.1"])
|
43
|
+
else
|
44
|
+
s.add_dependency(%q<localized_each_validator>, [">= 1.0.1"])
|
45
|
+
end
|
46
|
+
else
|
47
|
+
s.add_dependency(%q<localized_each_validator>, [">= 1.0.1"])
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'localized_each_validator'
|
2
|
+
|
3
|
+
# Validates email addresses. Uses the @invalid_email@ error message key.
|
4
|
+
#
|
5
|
+
# @example
|
6
|
+
# validates :email_address, email: true
|
7
|
+
#
|
8
|
+
# h2. Options
|
9
|
+
#
|
10
|
+
# | @:message@ | A custom message to use if the email is invalid. |
|
11
|
+
# | @:allow_nil@ | If true, @nil@ values are allowed. |
|
12
|
+
|
13
|
+
class EmailValidator < LocalizedEachValidator
|
14
|
+
error_key :invalid_email
|
15
|
+
|
16
|
+
# @private
|
17
|
+
def valid?(_, _, value)
|
18
|
+
value =~ /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: email_validation
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 1.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Tim Morgan
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-10-31 00:00:00 -07:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: localized_each_validator
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 0
|
30
|
+
- 1
|
31
|
+
version: 1.0.1
|
32
|
+
type: :runtime
|
33
|
+
prerelease: false
|
34
|
+
version_requirements: *id001
|
35
|
+
description: A simple, localizable EachValidator for email address fields in ActiveRecord 3.0.
|
36
|
+
email: git@timothymorgan.info
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.textile
|
44
|
+
files:
|
45
|
+
- .document
|
46
|
+
- .gitignore
|
47
|
+
- Gemfile
|
48
|
+
- Gemfile.lock
|
49
|
+
- LICENSE
|
50
|
+
- README.textile
|
51
|
+
- Rakefile
|
52
|
+
- VERSION
|
53
|
+
- email_validation.gemspec
|
54
|
+
- lib/email_validation.rb
|
55
|
+
has_rdoc: true
|
56
|
+
homepage: http://github.com/riscfuture/email_validation
|
57
|
+
licenses: []
|
58
|
+
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options:
|
61
|
+
- --charset=UTF-8
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
hash: -2013038120930311290
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
version: "0"
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
version: "0"
|
81
|
+
requirements: []
|
82
|
+
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 1.3.7
|
85
|
+
signing_key:
|
86
|
+
specification_version: 3
|
87
|
+
summary: Simple email validation in Rails 3
|
88
|
+
test_files: []
|
89
|
+
|