diff options
| author | Marin Jankovski <marin@gitlab.com> | 2014-06-11 13:04:30 +0200 |
|---|---|---|
| committer | Marin Jankovski <marin@gitlab.com> | 2014-06-11 13:04:30 +0200 |
| commit | e57fdc1190af582544154b77f0271ef9f206bc47 (patch) | |
| tree | 9c178deb4e7f5c130d6590d36213cdef87edf43c /lib | |
| parent | 1f5891e99183f1b20ced08d75dd44c9a01c48094 (diff) | |
| download | gitlab-ce-e57fdc1190af582544154b77f0271ef9f206bc47.tar.gz | |
Remove email_validator gem and allow apostrophe as a valid character in email.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/gitlab/email_validator.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/gitlab/email_validator.rb b/lib/gitlab/email_validator.rb new file mode 100644 index 00000000000..0a67ebcd795 --- /dev/null +++ b/lib/gitlab/email_validator.rb @@ -0,0 +1,21 @@ +# Based on https://github.com/balexand/email_validator +# +# Extended to use only strict mode with following allowed characters: +# ' - apostrophe +# +# See http://www.remote.org/jochen/mail/info/chars.html +# +class EmailValidator < ActiveModel::EachValidator + @@default_options = {} + + def self.default_options + @@default_options + end + + def validate_each(record, attribute, value) + options = @@default_options.merge(self.options) + unless value =~ /\A\s*([-a-z0-9+._']{1,64})@((?:[-a-z0-9]+\.)+[a-z]{2,})\s*\z/i + record.errors.add(attribute, options[:message] || :invalid) + end + end +end |
