Validate_CA
[ class tree: Validate_CA ] [ index: Validate_CA ] [ all elements ]

Class: Validate_CA

Source Location: /Validate_CA-0.1.2/Validate/CA.php

Class Overview


Data validation class for Canada


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • 1997-2005 Philippe Jausions

Methods


Inherited Variables

Inherited Methods


Class Details

[line 47]
Data validation class for Canada

This class provides methods to validate:

  • Social insurance number (aka SIN)
  • Province code
  • Telephone number
  • Postal code



[ Top ]


Method Detail

Luhn   [line 66]

bool Luhn( string $number)

Validates a number according to Luhn check algorithm

This function checks given number according Luhn check algorithm. It is published on several places, also here:


Parameters:

string   $number   —  to check

[ Top ]

phoneNumber   [line 224]

void phoneNumber( string $number, [bool $requireAreaCode = true])

Validates a Canadian phone number.

Canada and the United States share the same numbering plan, hence you can also call Validate_US::phoneNumber()

Can allow only seven digit numbers. Also allows the formats, (xxx) xxx-xxxx, xxx xxx-xxxx, And now x (xxx) xxx-xxxx or various combination without spaces or dashes. THIS SHOULD EVENTUALLY take a FORMAT in the options, instead

  • Access: public

Parameters:

string   $number   —  phone to validate
bool   $requireAreaCode   —  require the area code?

[ Top ]

postalCode   [line 121]

boolean postalCode( string $postalCode, [string $province = ''])

Validates a Canadian Postal Code

Parameters:

string   $postalCode   —  the postal code to validate
string   $province   —  against a the province code

[ Top ]

region   [line 186]

bool region( string $region)

Validates a "region" (i.e. province) code
  • Return: Whether the code is a valid province
  • Access: public

Parameters:

string   $region   —  2-letter province code

[ Top ]

ssn   [line 95]

bool ssn( string $ssn, [ $expiryDate = null], int $expiry_date)

Validates a Canadian social insurance number (SIN)

For unification between country-based validation packages, this method is named ssn()


Parameters:

string   $ssn   —  number to validate
int   $expiry_date   —  expiry date for SIN starting with a 9 (UNIX timestamp)
   $expiryDate   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:10:56 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.