[This is preliminary documentation and is subject to change.]

Validates a phone number as being correct for a given country. Returns a properly formatted international phone number.

Namespace:  PhoneSherpa.Services
Assembly:  App_Code.fxrph_yi (in App_Code.fxrph_yi)
Version: 0.0.0.0

Syntax

C#
public WS..::.ValidatePhoneNumberResult ValidatePhoneNumber(
	string AccessKey,
	string PhoneNumber,
	int CountryID
)
Visual Basic (Declaration)
Public Function ValidatePhoneNumber ( _
	AccessKey As String, _
	PhoneNumber As String, _
	CountryID As Integer _
) As WS..::.ValidatePhoneNumberResult
JScript
public function ValidatePhoneNumber(
	AccessKey : String, 
	PhoneNumber : String, 
	CountryID : int
) : WS..::.ValidatePhoneNumberResult

Parameters

AccessKey
Type: System..::.String
Security key allocated to a developer enabling access to the web service API.
PhoneNumber
Type: System..::.String
A phone number to be validated. International country dialing code is optional. Non-numerics are automatically removed from the input parameter.
CountryID
Type: System..::.Int32
Phone Sherpa internal identifier for a country. Returned phone number will all be formatted for the specified CountryID

Return Value

A validated phone number including the international dialing code. Listback formatting (Ex: ###-###-####) is not included. Numerics only.

Remarks

This function is typically used to validate input from a user interface form that is capturing phone numbers. If the phone number is missing digits, has additional digits, or does not meet the standardized dialing rules for the specified country, appropriate error codes are returned. The successfully validated phone number should be used for all API calls requring an InternationalPhoneNumber.

Below is an example of how to use this function:

CopyVB.NET
Function Validate_Phone_Number(ByVal UserPhoneNumber As String, ByVal CountryID As Integer) As String
    Dim SherpaService As New PhoneSherpa.Services.WS

    Dim Validate_Response As PhoneSherpa.Services.ValidatedPhoneNumberResult = Nothing

    Validate_Response = SherpaService.ValidatePhoneNumber("My_WSAccessKey", UserPhoneNumber, CountryID)

    If Validate_Response.Result.ErrorCode = 0 Then
        'Use the returned user phone number subsequent calls requiring this parameter
        Return Validate_Response.InterationalPhoneNumber
    Else
        'error - failed validating user phone number or the phone information is not valid.
        'Display validation specific failures to the user.  
        'Merchant code should use thier own messaging rather than the raw error message in the response
        Return Validate_Response.Result.ErrorMessage
    End If
End Function

See Also