mikoweb / polish-validator-bundle
用于验证波兰身份证号码的Symfony扩展包:PESEL、NIP、REGON。
v1.1.1
2016-12-14 12:15 UTC
Requires
- php: >=5.3.1
- kiczort/polish-validator: ^1.0
- symfony/framework-bundle: ~2.1|~3.0
- symfony/validator: ^2.1|~3.0
Requires (Dev)
- phpunit/phpunit: 4.8
This package is auto-updated.
Last update: 2024-09-25 06:56:06 UTC
README
这是一个用于验证波兰身份证号码(如PESEL、NIP、REGON)的Symfony2扩展包。
安装
推荐使用 Composer 安装此库。
# Install Composer curl -sS https://getcomposer.org/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 KiczortPolishValidatorBundle\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 KiczortPolishValidatorBundle\Validator\Constraints as KiczortAssert; class Person { /** * @KiczortAssert\Nip */ protected $nip; }
RegonValidator使用示例
... // src/AppBundle/Entity/Company.php namespace AppBundle\Entity; use KiczortPolishValidatorBundle\Validator\Constraints as KiczortAssert; class Company { /** * @KiczortAssert\Regon */ protected $regon; }
错误追踪
GitHub问题。如果您发现了错误,请创建一个问题。
MIT许可证
许可证可以在 此处 找到。