Cake\Localized\Validation\CnValidation::postal PHP 메소드

postal() 공개 정적인 메소드

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.
리턴 boolean Success.
    public static function postal($check)
    {
        $pattern = '/^[0-9]{6}$/';
        return (bool) preg_match($pattern, $check);
    }

Usage Example

예제 #1
0
 /**
  * test the postal method of CnValidation
  *
  * @return void
  */
 public function testPostal()
 {
     $this->assertTrue(CnValidation::postal('350000'));
     $this->assertTrue(CnValidation::postal('123456'));
     $this->assertFalse(CnValidation::postal('10075'));
     $this->assertFalse(CnValidation::postal('10x'));
     $this->assertFalse(CnValidation::postal('0851234'));
 }