is_valid_number_for_region

is_valid_number_for_region

Tests whether a phone number is valid for a certain region.

This action makes use of the default_region parameter.

Consider the following dialplan fragments:

  <action application="phonenumber" data="is_valid_number_for_region caller default_region=US"/>

will set the phonenumber_caller_valid_number_for_region channel variable to the resulting value.


  <action application="phonenumber" data="is_valid_number_for_region destination default_region=US"/>

will set the phonenumber_destination_valid_number_for_region channel variable to the resulting value.


  <action application="phonenumber" data="is_valid_number_for_region all default_region=US"/>

will set both the phonenumber_caller_valid_number_for_region and the phonenumber_destination_valid_number_for_region channel variables to the resulting value.


  <action application="phonenumber" data="is_valid_number_for_region ${variable} default_region=US"/>

will set the phonenumber_number_valid_number_for_region channel variable to the resulting value.

freeswitch@test> phonenumber is_valid_number_for_region 6172531000 default_region=US

true

freeswitch@test> phonenumber is_valid_number_for_region 6172531000 default_region=GB

false

freeswitch@test> phonenumber is_valid_number_for_region 07400982200 default_region=GB

true

freeswitch@test> phonenumber is_valid_number_for_region 07400982200 default_region=DE

true

freeswitch@test> phonenumber is_valid_number_for_region 07400982200 default_region=IT

false

freeswitch@test> phonenumber is_valid_number_for_region 800FLOWERS default_region=US

true

freeswitch@test> phonenumber is_valid_number_for_region 800FLOWERS default_region=CA

true

freeswitch@test> phonenumber is_valid_number_for_region 800FLOWERS default_region=JM

true

Consider the following hook definitions:

    <hook>
      <param name="scope" value="caller"/>
      <param name="actions" value="is_valid_number_for_region"/>
      <param name="default_region" value="US"/>
    </hook>

will set the phonenumber_caller_valid_number_for_region channel variable to the resulting value.


    <hook>
      <param name="scope" value="destination"/>
      <param name="actions" value="is_valid_number_for_region"/>
      <param name="default_region" value="US"/>
    </hook>

will set the phonenumber_destination_valid_number_for_region channel variable to the resulting value.


    <hook>
      <param name="scope" value="all"/>
      <param name="actions" value="is_valid_number_for_region"/>
      <param name="default_region" value="US"/>
    </hook>

will set both the phonenumber_caller_valid_number_for_region and the phonenumber_destination_valid_number_for_region channel variables to the resulting value.