Cake\Localized\Validation\RsValidation::addressCode PHP Method

addressCode() public static method

Checks an address code (Adresni kod) for Serbia.
public static addressCode ( string $check ) : boolean
$check string The value to check.
return boolean Success.
    public static function addressCode($check)
    {
        $pattern = '/^[0-9]{6}$/';
        return (bool) preg_match($pattern, $check);
    }

Usage Example

Beispiel #1
0
 /**
  * test the address_code method of RsValidation
  *
  * @return void
  */
 public function testAddressCode()
 {
     $this->assertTrue(RsValidation::addressCode('122407'));
     $this->assertFalse(RsValidation::addressCode('11090'));
     $this->assertFalse(RsValidation::addressCode('A11090'));
 }