add valid email regex in user.rb

This commit is contained in:
rahul 2017-07-26 22:31:54 +05:30
parent edd0024a17
commit 72c4e9f24c

View file

@ -64,7 +64,8 @@ class User < ActiveRecord::Base
scope :admin, -> { where(is_admin: true) }
scope :active, -> { where(is_disabled: false) }
validates :email, presence: true
VALID_EMAIL_REGEX = /\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i
validates :email, presence: true, format: {with: VALID_EMAIL_REGEX }
validates :username,
uniqueness: {