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

Class: Validate_US

Source Location: /Validate_US-0.5.2/Validate/US.php

Class Overview


Data validation class for the United States


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • 1997-2005 Brent Cook

Methods


Inherited Variables

Inherited Methods


Class Details

[line 48]
Data validation class for the United States

This class provides methods to validate:

  • Social insurance number (aka SSN)
  • Region (state code)
  • Postal code
  • Telephone number



[ Top ]


Method Detail

phoneNumber   [line 300]

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

Validate a US phone number.

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

  • Return: The valid or invalid phone number

Parameters:

string   $number   —  phone to validate
bool   $requireAreaCode   —  require the area code? (default: true)

[ Top ]

postalCode   [line 217]

boolean postalCode( string $postalCode, [bool $strong = false])

Validates a US Postal Code format (ZIP code)
  • Return: TRUE if code is valid, FALSE otherwise
  • Todo: Integrate with USPS web API
  • Access: public

Parameters:

string   $postalCode   —  the ZIP code to validate
bool   $strong   —  optional; strong checks (e.g. against a list of postcodes) (not implanted)

[ Top ]

region   [line 229]

bool region( string $region)

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

Parameters:

string   $region   —  2-letter state code

[ Top ]

ssn   [line 56]

bool ssn( string $ssn, [array $high_groups = null])

Validates a social security number

Parameters:

string   $ssn   —  number to validate
array   $high_groups   —  array of highest issued SSN group numbers

[ Top ]

ssnCheck   [line 118]

void ssnCheck( int $area, int $group, int $serial, array $high_groups)

checks if a Social Security Number is valid

needs the first three digits and first two digits and the final four digits as separate integer parameters


Parameters:

int   $area   —  3-digit group in a SSN
int   $group   —  2-digit group in a SSN
int   $serial   —  4-digit group in a SSN
array   $high_groups   —  array of highest issued group numbers area number=>group number

[ Top ]

ssnGetHighGroups   [line 162]

array ssnGetHighGroups( [string $uri = 'http://www.ssa.gov/employer/highgroup.txt'], [bool $is_text = false])

Gets the most current list the highest SSN group numbers issued from the Social Security Administration website. This info can be cached for performance (and to lessen the load on the SSA website)

Parameters:

string   $uri   —  Path to the SSA highgroup.htm file
bool   $is_text   —  Take the $uri param as directly the contents

[ Top ]

ssnGroupRange   [line 86]

int ssnGroupRange( int $groupNumber)

Returns a range for a supplied group number, which is the middle, two-digit field of a SSN.

Group numbers are defined as follows:

  1. - Odd numbers, 01 to 09
  2. - Even numbers, 10 to 98
  3. - Even numbers, 02 to 08
  4. - Odd numbers, 11 to 99


Parameters:

int   $groupNumber   —  a group number to check, 00-99

[ Top ]


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