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

personId() public static method

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

Usage Example

Beispiel #1
0
 /**
  * test the ssn method of DkValidation
  *
  * @return void
  */
 public function testSsn()
 {
     $this->assertTrue(DkValidation::personId('111111-3334'));
     $this->assertFalse(DkValidation::personId('111111-333'));
 }