Tests not working. Not sure why.
This commit is contained in:
@@ -1,4 +1,16 @@
|
||||
class Virtual < ApplicationRecord
|
||||
validate :domain_name_exists
|
||||
validates :email, presence: true
|
||||
validates :destination, presence: true
|
||||
|
||||
def domain_name_exists
|
||||
if email.present?
|
||||
if !email.index("@").nil?
|
||||
split_email = email.split("@")
|
||||
if !Domain.exists?(domain: split_email[1])
|
||||
errors.add(:email, "domain must be looked after by this server")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user