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

postal() public static method

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

Usage Example

Example #1
0
 /**
  * test the postal method of TrValidation
  *
  * @return void
  */
 public function testPostal()
 {
     $this->assertTrue(TrValidation::postal('02300'));
     $this->assertFalse(TrValidation::postal('2300'));
     $this->assertFalse(TrValidation::postal('230000'));
 }