Cake\Localized\Validation\IdValidation::postal PHP Method

postal() public static method

Checks a postal code for Indonesia.
public static postal ( string $check ) : boolean
$check string The value to check.
return boolean Success.
    public static function postal($check)
    {
        $pattern = '/[1-9][0-9]{4}/';
        return (bool) preg_match($pattern, $check);
    }

Usage Example

Beispiel #1
0
 /**
  * Test the postal method of IdValidation
  *
  * @return void
  */
 public function testPostal()
 {
     $this->assertTrue(IdValidation::postal('15000'));
     $this->assertFalse(IdValidation::postal('00091'));
 }