Commit e57fdc1190af582544154b77f0271ef9f206bc47
1 parent
1f5891e9
Exists in
spb-stable
and in
2 other branches
Remove email_validator gem and allow apostrophe as a valid character in email.
Showing
3 changed files
with
21 additions
and
6 deletions
Show diff stats
Gemfile
| ... | ... | @@ -50,9 +50,6 @@ gem "grape", "~> 0.6.1" |
| 50 | 50 | gem "grape-entity", "~> 0.4.2" |
| 51 | 51 | gem 'rack-cors', require: 'rack/cors' |
| 52 | 52 | |
| 53 | -# Email validation | |
| 54 | -gem "email_validator", "~> 1.4.0", :require => 'email_validator/strict' | |
| 55 | - | |
| 56 | 53 | # Format dates and times |
| 57 | 54 | # based on human-friendly examples |
| 58 | 55 | gem "stamp" | ... | ... |
Gemfile.lock
| ... | ... | @@ -110,8 +110,6 @@ GEM |
| 110 | 110 | email_spec (1.5.0) |
| 111 | 111 | launchy (~> 2.1) |
| 112 | 112 | mail (~> 2.2) |
| 113 | - email_validator (1.4.0) | |
| 114 | - activemodel | |
| 115 | 113 | emoji (1.0.1) |
| 116 | 114 | json |
| 117 | 115 | enumerize (0.7.0) |
| ... | ... | @@ -591,7 +589,6 @@ DEPENDENCIES |
| 591 | 589 | diffy (~> 3.0.3) |
| 592 | 590 | dropzonejs-rails |
| 593 | 591 | email_spec |
| 594 | - email_validator (~> 1.4.0) | |
| 595 | 592 | enumerize |
| 596 | 593 | factory_girl_rails |
| 597 | 594 | ffaker | ... | ... |
| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | +# Based on https://github.com/balexand/email_validator | |
| 2 | +# | |
| 3 | +# Extended to use only strict mode with following allowed characters: | |
| 4 | +# ' - apostrophe | |
| 5 | +# | |
| 6 | +# See http://www.remote.org/jochen/mail/info/chars.html | |
| 7 | +# | |
| 8 | +class EmailValidator < ActiveModel::EachValidator | |
| 9 | + @@default_options = {} | |
| 10 | + | |
| 11 | + def self.default_options | |
| 12 | + @@default_options | |
| 13 | + end | |
| 14 | + | |
| 15 | + def validate_each(record, attribute, value) | |
| 16 | + options = @@default_options.merge(self.options) | |
| 17 | + unless value =~ /\A\s*([-a-z0-9+._']{1,64})@((?:[-a-z0-9]+\.)+[a-z]{2,})\s*\z/i | |
| 18 | + record.errors.add(attribute, options[:message] || :invalid) | |
| 19 | + end | |
| 20 | + end | |
| 21 | +end | ... | ... |