Add email validator

#186
This commit is contained in:
Artur Beljajev 2016-11-23 18:09:55 +02:00
parent 968a59cd3d
commit a5c0333a5d
2 changed files with 17 additions and 1 deletions

View file

@ -23,7 +23,7 @@ module Registry
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
config.time_zone = ENV['time_zone'] || 'Tallinn' # NB! It should be defined,
config.time_zone = ENV['time_zone'] || 'Tallinn' # NB! It should be defined,
# otherwise ActiveRecord usese other class internally.
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.yml').to_s]
@ -35,6 +35,7 @@ module Registry
# Autoload all model subdirs
config.autoload_paths += Dir[Rails.root.join('app', 'models', '**/')]
config.autoload_paths << Rails.root.join('lib')
config.eager_load_paths << config.root.join('lib', 'validators')
# Add the fonts path
config.assets.paths << Rails.root.join('vendor', 'assets', 'fonts')

View file

@ -0,0 +1,15 @@
class EmailValidator
def self.regexp
Devise::email_regexp
end
def initialize(email)
@email = email
end
def valid?
email =~ self.class.regexp
end
attr_reader :email
end