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

postal() public static method

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

Usage Example

Beispiel #1
0
 /**
  * test the postal method of DkValidation
  *
  * @return void
  */
 public function testPostal()
 {
     $this->assertTrue(DkValidation::postal('4444'));
     $this->assertFalse(DkValidation::postal('333'));
     $this->assertFalse(DkValidation::postal('55555'));
 }