module Roqua::Healthy::A19::PhoneValidator

Constants

EU_COUNTRY_CODES

Public Class Methods

contains_only_phone_number_characters?(number) click to toggle source
# File lib/roqua/healthy/a19/phone_validator.rb, line 26
def self.contains_only_phone_number_characters?(number)
  /^\+?\d+$/.match(number).present?
end
phone_cell_number?(number) click to toggle source
# File lib/roqua/healthy/a19/phone_validator.rb, line 13
def self.phone_cell_number?(number)
  stripped_number = strip_non_phone_number_characters(number)

  phone_cell_number_in_european_country?(stripped_number) &&
    contains_only_phone_number_characters?(stripped_number)
end
phone_cell_number_in_european_country?(number) click to toggle source
# File lib/roqua/healthy/a19/phone_validator.rb, line 20
def self.phone_cell_number_in_european_country?(number)
  phone = Phonelib.parse(number, 'NL')

  phone.type == :mobile && EU_COUNTRY_CODES.include?(phone.country)
end
strip_non_phone_number_characters(number) click to toggle source
# File lib/roqua/healthy/a19/phone_validator.rb, line 30
def self.strip_non_phone_number_characters(number)
  number.gsub(/[-\s.]/, '')
end