lib/phonelib/phone_analyzer_helper.rb
# constructs full regex for phone validation for provided phone data
# (international prefix, country code, national prefix, valid number)
#
# ==== Attributes
#
# * +data+ - country data hash
# * +country_optional+ - whether to put country code as optional group
constructs full regex for phone validation for provided phone data
(international prefix, country code, national prefix, valid number)

Attributes

+data+ - country data hash
+country_optional+ - whether to put country code as optional group
constructs full regex for phone validation for provided phone data ( international prefix country code national prefix valid number ) Attributes + data + - country data hash + country_optional + - whether to put country code as optional group
def full_regex_for_data(data, type, country_optional = true)
      regex = []
      regex << '0{2}?'
      regex << "(#{data[Core::INTERNATIONAL_PREFIX]})?"
      regex << "(#{data[Core::COUNTRY_CODE]})#{country_optional ? '?' : ''}"
      regex << "(#{data[Core::NATIONAL_PREFIX_FOR_PARSING] || data[Core::NATIONAL_PREFIX]})?"
      regex << "(#{type_regex(data[Core::TYPES][Core::GENERAL], type)})" if data[Core::TYPES]
      cr("^#{regex.join}$")
    end
def full_regex_for_data ( data , type , country_optional = true ) regex = [ ] regex << '0{2}?' regex << "(#{data[Core::INTERNATIONAL_PREFIX]})?" regex << "(#{data[Core::COUNTRY_CODE]})#{country_optional ? '?' : ''}" regex << "(#{data[Core::NATIONAL_PREFIX_FOR_PARSING] || data[Core::NATIONAL_PREFIX]})?" regex << "(#{type_regex(data[Core::TYPES][Core::GENERAL], type)})" if data [ Core :: TYPES ] cr ( "^#{regex.join}$" ) end
constructs full regex for phone validation for provided phone data
(international prefix, country code, national prefix, valid number)
constructs full regex for phone validation for provided phone data ( international prefix country code national prefix valid number )
data
<not_specific>
type
<not_specific>
country_optional
<not_specific>