List of available validations

List of available validations – available validation in Validate_AU

Validate a Australian TFN / SSN

Most Australian's will have a TFN (Tax File Number) however not all, it is the closet equivalent we have to a Social Security Number. Note that this validation routine can be accessed through both Validate_AU::tfn() and Valdiate::ssn() methods.

sample

<?php

// Include the package
require_once('Validate/AU.php');

$badTFN '23 456 782';
$result Validate_AU::tfn($badTFN);
echo 
'Test ' $badTFN .' : <br />';
var_export($result);

echo 
'<br /><br />';
$goodTFN '123 456 782';
$result Validate_AU::tfn($goodTFN);
echo 
'Test ' $goodNationalId .' : <br />';
var_export($result);
?>

Output :

     
Test 23 456 782 :
false

Test 123 456 782 :
true
     
    

Validate a Australian postcode

Australian post code are 4 digit formed.

First parameter is the post code to validate.

An optional parameter for activate strong checks using a list of postcodes.

sample

<?php

// Include the package
require_once('Validate/AU.php');

$badPostCode 'ABCD';
$result Validate_AU::postalCode($badPostCode);
echo 
'Test ' $badPostCode .' : <br />';
var_export($result);

echo 
'<br /><br />';
$goodPostCode '3000';
$result Validate_AU::postalCode($goodPostCode);
echo 
'Test ' $goodPostCode .' : <br />';
var_export($result);
?>

Output :

     
Test ABCD :
false

Test 3000 :
true
     
    

sample using strong parameter

1234 appears to be a valid 4 digit postcode, however it does not appear in the official list.

<?php

// Include the package
require_once('Validate/AU.php');

$badPostCode '1234';
$goodPostCode '7930';

$result Validate_AU::postalCode($badPostCode);
echo 
'Test ' $badPostCode .' : <br />';
var_export($result);

$result Validate_AU::postalCode($badPostCodefalse);
echo 
'<br /><br />Test ' $badPostCode .' : <br />';
var_export($result);

$result Validate_AU::postalCode($badPostCodetrue);
echo 
'<br /><br />Test ' $badPostCode .' : <br />';
var_export($result);

$result Validate_AU::postalCode($goodPostCodetrue);
echo 
'<br /><br />Test ' $goodPostCode .' : <br />';
var_export($result);
?>

Output :

     
Test 1234 :
true

Test 1234 :
true

Test 1234 :
false

Test 7930 :
true
     
    

Validate an ABN

Validate an Australian Business Number.

sample

<?php

// Include the package
require_once('Validate/AU.php');

$badABN '00 043 145 470';
$result Validate_AU::abn($badABN);
echo 
'Test ' $badRegion .' : <br />';
var_export($result);

echo 
'<br /><br />';
$goodABN '28 043 145 470';
$result Validate_AU::abn($goodABN);
echo 
'Test ' $goodRegion .' : <br />';
var_export($result);
?>

Output :

     
Test 00 043 145 470 :
false

Test 28 043 145 470 :
true
     
    

Validate a Region / State

Validates a 2/3 region (state) code.

sample

<?php

// Include the package
require_once('Validate/AU.php');

$badRegion 'asdf';
$result Validate_AU::region($badVAT);
echo 
'Test ' $badRegion .' : <br />';
var_export($result);

echo 
'<br /><br />';
$goodRegion 'VIC';
$result Validate_AU::region($goodRegion);
echo 
'Test ' $goodRegion .' : <br />';
var_export($result);
?>

Output :

     
Test asdf :
false

Test VIC :
true
     
    

Validate a phonenumber

Validate an Australian phone number passed as first param. Second parameter can be used to specify flags that signify the type of number to be validated.

Flags can be any combination of the bitwise constants VALIDATE_AU_PHONENUMBER_* as follows:

Validate_AU Phone Number Flags
Flag Description
"VALIDATE_AU_PHONENUMBER_STRICT" If supplied then no spaces, parenthesis or dashes (-) will be removed.
"VALIDATE_AU_PHONENUMBER_NATIONAL" If supplied, then valid national numbers, both landline and mobile will pass validation.
"VALIDATE_AU_PHONENUMBER_INDIAL" If supplied, then valid indial (13/1300/1800/1900) numbers will pass validation.
"VALIDATE_AU_PHONENUMBER_INTERNATIONAL" If supplied, then valid international syntax will pass validation. EG. +61.3 9999 9999

sample

<?php

// Include the package
require_once('Validate/AU.php');

$nationalPhone       '03 9999 9999';
$nationalStrictPhone '0399999999';
$indialPhone         '1300 131 121';
$internationalSyntax '+61.3 8779 7212';

echo 
'Test ' $goodPhone .' : <br />';
$result Validate_AU::phoneNumber($nationalPhone); // the flag VALIDATE_AU_PHONENUMBER_NATIONAL is default
var_export($result) . '-';
$result Validate_AU::phoneNumber($nationalPhoneVALIDATE_AU_PHONENUMBER_NATIONAL VALIDATE_AU_PHONENUMBER_STRICT);
var_export($result) . '-';
$result Validate_AU::phoneNumber($nationalPhoneVALIDATE_AU_PHONENUMBER_INDIAL);
var_export($result) . '-';
$result Validate_AU::phoneNumber($nationalPhoneVALIDATE_AU_PHONENUMBER_INTERNATIONAL);
var_export($result) . '-';
$result Validate_AU::phoneNumber($nationalPhoneVALIDATE_AU_PHONENUMBER_NATIONAL VALIDATE_AU_PHONENUMBER_INDIAL VALIDATE_AU_PHONENUMBER_INTERNATIONAL);
var_export($result);

echo 
'<br /><br />';
echo 
'Test ' $nationalStrictPhone .' : <br />';
$result Validate_AU::phoneNumber($nationalStrictPhone);
var_export($result) . '-';
$result Validate_AU::phoneNumber($nationalStrictPhoneVALIDATE_AU_PHONENUMBER_NATIONAL VALIDATE_AU_PHONENUMBER_STRICT);
var_export($result) . '-';
$result Validate_AU::phoneNumber($nationalStrictPhoneVALIDATE_AU_PHONENUMBER_INDIAL);
var_export($result) . '-';
$result Validate_AU::phoneNumber($nationalStrictPhoneVALIDATE_AU_PHONENUMBER_INTERNATIONAL);
var_export($result) . '-';
$result Validate_AU::phoneNumber($nationalStrictPhoneVALIDATE_AU_PHONENUMBER_NATIONAL VALIDATE_AU_PHONENUMBER_INDIAL VALIDATE_AU_PHONENUMBER_INTERNATIONAL);
var_export($result) . '-';

echo 
'<br /><br />';
echo 
'Test ' $indialPhone .' : <br />';
$result Validate_AU::phoneNumber($indialPhone);
var_export($result) . '-';
$result Validate_AU::phoneNumber($indialPhoneVALIDATE_AU_PHONENUMBER_INDIAL VALIDATE_AU_PHONENUMBER_STRICT);
var_export($result) . '-';
$result Validate_AU::phoneNumber($indialPhoneVALIDATE_AU_PHONENUMBER_INDIAL);
var_export($result) . '-';
$result Validate_AU::phoneNumber($indialPhoneVALIDATE_AU_PHONENUMBER_INTERNATIONAL);
var_export($result) . '-';
$result Validate_AU::phoneNumber($indialPhoneVALIDATE_AU_PHONENUMBER_NATIONAL VALIDATE_AU_PHONENUMBER_INDIAL VALIDATE_AU_PHONENUMBER_INTERNATIONAL);
var_export($result) . '-';
echo 
'<br /><br />';

echo 
'Test ' $internationalSyntax .' : <br />';
$result Validate_AU::phoneNumber($internationalSyntax);
var_export($result) . '-';
$result Validate_AU::phoneNumber($internationalSyntaxVALIDATE_AU_PHONENUMBER_INTERNATIONAL VALIDATE_AU_PHONENUMBER_STRICT);
var_export($result) . '-';
$result Validate_AU::phoneNumber($internationalSyntaxVALIDATE_AU_PHONENUMBER_INDIAL);
var_export($result) . '-';
$result Validate_AU::phoneNumber($internationalSyntaxVALIDATE_AU_PHONENUMBER_INTERNATIONAL);
var_export($result) . '-';
$result Validate_AU::phoneNumber($internationalSyntaxVALIDATE_AU_PHONENUMBER_NATIONAL VALIDATE_AU_PHONENUMBER_INDIAL VALIDATE_AU_PHONENUMBER_INTERNATIONAL);
var_export($result) . '-';

?>

Output :

     
Test 03 9999 9999 :
true - false - false - false - true

Test 0399999999 :
true - true - false - false - true

Test 1300 131 121 :
false - false - true - false - true

Test +61.3 8779 7212 :
false - false - true - true - true
     
    
introduction to Validate_AU (Previous) Constants defined in and used by Validate_AU (Next)
Last updated: Mon, 22 Sep 2014 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

There are no user contributed notes for this page.