jongotlin/identity-number-bundle

2.0.0 2022-02-14 13:41 UTC

This package is auto-updated.

Last update: 2024-09-14 19:53:24 UTC


README

Build Status

此Symfony Bundle使用github.com/byrokrat/id来验证瑞典身份证号码(personnummer)、协调号码(samordningsnummer)和组织号码(organisationsnummer)。

安装

通过Composer

$ composer require jongotlin/identity-number-bundle
class AppKernel extends Kernel
{
  public function registerBundles()
  {
    $bundles = array(
        // ...
        new JGI\IdentityNumberValidatorBundle\IdentityNumberValidatorBundle(),
    }
  }
}

使用方法

use JGI\IdentityNumberValidatorBundle\Validator\Constraints as IdentityNumberAssert;

/**
 * @IdentityNumberAssert\IdentityNumber(allowCoordinationNumber=true)
 */
private $identityNumber;

/**
 * @IdentityNumberAssert\OrganizationNumber(allowPersonalIdNumber=true, allowCoordinationNumber=true)
 */
private $organizationNumber;

可用的选项包括

  • allowCoordinationNumber 当设置为true时,接受协调号码(samordningsnummer)。默认为false。
  • allowPersonalIdNumber 当设置为true时,个人身份证号码作为组织号码接受。默认为false。
  • strict 当设置为true时,身份证号码必须是12位,组织号码必须是10位。不接受连字符。如果为false,身份证号码可以是10或12位,带或不带连字符(或加号)。默认为false。