PHP Class Cake\Localized\Validation\CnValidation

Inheritance: extends LocalizedValidation
Show file Open project: cakephp/localized Class Usage Examples

Public Methods

Method Description
personId ( string $check ) : boolean Checks national identify number for The Peoples Republic of China (mainland).
phone ( string $check ) : boolean Checks phone numbers for The Peoples Republic of China (mainland)
postal ( string $check ) : boolean Checks a postal code for The Peoples Republic of China (mainland)

Method Details

personId() public static method

Compliant with GB11643-1999 national standard.
public static personId ( string $check ) : boolean
$check string The value to check.
return boolean Success.

phone() public static method

It is not a strict rule and should cover almost all legal phone numbers. Some (obviously) illegal phone numbers will pass this test, especially cellphone. Since it will be a hard task to maintain a small cellphone prefix "database", just make it simple for now.
public static phone ( string $check ) : boolean
$check string The value to check.
return boolean Success.

postal() public static method

In fact the national standard allows to omit the final two digits if they are both 0, but few people write postal number in this way nowadays.
public static postal ( string $check ) : boolean
$check string The value to check.
return boolean Success.