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

personId() public static method

Checks a country specific identification number.
public static personId ( string $check ) : boolean
$check string The value to check.
return boolean Success.
    public static function personId($check)
    {
        $checks = ['dni', 'nie', 'nif'];
        foreach ($checks as $method) {
            if (static::$method($check)) {
                return true;
            }
        }
        return false;
    }

Usage Example

Example #1
0
 /**
  * test the personId method of EsValidation
  *
  * @return void
  */
 public function testPersonId()
 {
     $this->assertTrue(EsValidation::personId('32050031Z'));
     $this->assertTrue(EsValidation::personId('X2546874S'));
     $this->assertTrue(EsValidation::personId('K1254868A'));
     $this->assertFalse(EsValidation::personId('23232323'));
 }