adamaru/polish-validator-bundle

此包已被放弃且不再维护。未建议替代包。

Symfony 扩展包,包含用于波兰身份号码的验证器:PESEL、NIP、REGON、PWZ。

1.2.0 2019-02-08 13:11 UTC

This package is auto-updated.

Last update: 2022-03-08 20:56:52 UTC


README

License Version

这是一个用于波兰身份号码(如PESEL、NIP、REGON和PWZ)验证器的Symfony 3/4 扩展包。

安装

composer require adamaru/polish-validator-bundle

将包添加到 AppKernel.php

    public function registerBundles()
        {
            $bundles = array(
                ...
                new Kiczort\PolishValidatorBundle\KiczortPolishValidatorBundle(),
                ...
            );
            
            return $bundles;
        }

文档

使用PESELValidator的示例

在实际世界中存在有错误的PESEL号码,因此在此验证器中,校验和检查仅适用于严格模式。在非严格模式下,它检查长度、使用的字符和出生日期的正确性。

...
// src/AppBundle/Entity/Person.php
namespace AppBundle\Entity;

use Kiczort\PolishValidatorBundle\Validator\Constraints  as KiczortAssert;

class Person
{
    /**
     * @KiczortAssert\Pesel(
     *     message = "The '{{ value }}' is not a valid PESEL number.",
     *     strict = true
     * )
     */
     protected $pesel;
}

使用NipValidator的示例

...
// src/AppBundle/Entity/Person.php
namespace AppBundle\Entity;

use Kiczort\PolishValidatorBundle\Validator\Constraints as KiczortAssert;

class Person
{
    /**
     * @KiczortAssert\Nip
     */
     protected $nip;
}

使用RegonValidator的示例

...
// src/AppBundle/Entity/Company.php
namespace AppBundle\Entity;

use Kiczort\PolishValidatorBundle\Validator\Constraints as KiczortAssert;

class Company
{
    /**
     * @KiczortAssert\Regon
     */
     protected $regon;
}

使用PwzValidator的示例

PWZ表示“执业许可”(pl. “prawo wykonywania zawodu”),是给NIL(波兰医生和牙医协会)医生的号码。验证器也接受空字符串和null,因此您需要自己添加“Assert/NotBlank”。

...
// src/AppBundle/Entity/Company.php
namespace AppBundle\Entity;

use Kiczort\PolishValidatorBundle\Validator\Constraints  as KiczortAssert;

class Doctor
{
    /**
     * @KiczortAssert\Pwz
     */
     protected $pwz;
}

错误跟踪

GitHub 问题。如果您发现了错误,请创建一个问题。

MIT许可证

许可证可以在这里找到。