fix: Check phone_number and email changes are exist before validation (#4551)

This commit is contained in:
Muhsin Keloth
2022-04-26 15:13:28 +05:30
committed by GitHub
parent fa031a0e2d
commit 3a5e34fccb
2 changed files with 41 additions and 3 deletions

View File

@@ -145,13 +145,13 @@ class Contact < ApplicationRecord
def phone_number_format
return if phone_number.blank?
self.phone_number = changes['phone_number'].first unless phone_number.match?(/\+[1-9]\d{1,14}\z/)
self.phone_number = phone_number_was unless phone_number.match?(/\+[1-9]\d{1,14}\z/)
end
def email_format
return if email.blank?
self.email = changes['email'].first unless email.match(Devise.email_regexp)
self.email = email_was unless email.match(Devise.email_regexp)
end
def prepare_contact_attributes