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

postal() public static method

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

Usage Example

Beispiel #1
0
 /**
  * test the postal method of RoValidation
  *
  * @return void
  */
 public function testPostal()
 {
     $this->assertTrue(RoValidation::postal('517006'));
     $this->assertFalse(RoValidation::postal('23708'));
     $this->assertFalse(RoValidation::postal('23 708'));
 }