mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 18:26:06 +02:00
parent
0f352cab24
commit
d520b5b157
50 changed files with 2462 additions and 323 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