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

personId() public static method

Checks a social security number for Norway.
public static personId ( string $check ) : boolean
$check string The value to check.
return boolean Success.
    public static function personId($check)
    {
        $pattern = '/^(\\d{11})|(\\d{6} \\d{5})$/';
        return (bool) preg_match($pattern, $check);
    }

Usage Example

Beispiel #1
0
 /**
  * test the ssn method of NoValidation
  *
  * @return void
  */
 public function testSsn()
 {
     $this->assertTrue(NoValidation::personId('12345678901'));
     $this->assertTrue(NoValidation::personId('123456 78901'));
     $this->assertFalse(NoValidation::personId('1234567890'));
     $this->assertFalse(NoValidation::personId('123456 7890'));
 }