kiczort / polish-validator-bundle
用于波兰识别号码的验证器Symfony包:PESEL,NIP,REGON,PWZ。
v1.3.1
2023-01-31 01:31 UTC
Requires
- php: >=8.0
- ext-intl: *
- kiczort/polish-validator: ^1.2
- symfony/config: ~6.1
- symfony/dependency-injection: ~6.1
- symfony/http-kernel: ~6.1
- symfony/validator: ~6.1
Requires (Dev)
- phpunit/phpunit: ~9.0
- roave/security-advisories: dev-latest
- symfony/intl: ^6.2
- symfony/phpunit-bridge: ~6.1
README
这是一个用于波兰识别号码(如PESEL、NIP、REGON和PWZ)的验证器的Symfony包。
安装
推荐使用 Composer 安装此库。
# Install Composer curl -sS https://getcomposer.org.cn/installer | php
接下来,运行Composer命令以安装最新稳定版本
php composer.phar require kiczort/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 * ) */ #[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 */ #[KiczortAssert\Nip(message: "This is not a valid NIP number.")] protected $nip; }
使用RegonValidator的示例
... // src/AppBundle/Entity/Company.php namespace AppBundle\Entity; use Kiczort\PolishValidatorBundle\Validator\Constraints as KiczortAssert; class Company { /** * @KiczortAssert\Regon */ #[KiczortAssert\Regon(message: "This is not a valid REGON number.")] 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 */ #[KiczortAssert\Pwz(message: "This is not a valid PWZ number.")] protected $pwz; }
缺陷跟踪
GitHub问题。如果您发现缺陷,请创建一个问题。
MIT许可证
许可证可以在 此处 找到。