mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 17:37:17 +02:00
parent
9e8f806a43
commit
71b92afba3
2 changed files with 6 additions and 6 deletions
|
@ -2,11 +2,11 @@ class PhoneValidator < ActiveModel::EachValidator
|
|||
def validate_each(record, attribute, value)
|
||||
return if record.errors[:phone].any?
|
||||
|
||||
splitted_phone = value.split('.')
|
||||
country_code = splitted_phone.first
|
||||
phone_number = splitted_phone.second
|
||||
phone_parts = value.split('.')
|
||||
country_code = phone_parts.first
|
||||
subscriber_no = phone_parts.second
|
||||
|
||||
if zeros_only?(country_code) || zeros_only?(phone_number)
|
||||
if zeros_only?(country_code) || zeros_only?(subscriber_no)
|
||||
record.errors.add(attribute, :invalid)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue