This is Symfony bundle with validators for Polish identification numbers like: PESEL, NIP, REGON and PWZ.
The recommended way to install this library is Composer.
# Install Composer
curl -sS https://getcomposer.org/installer | php
Next, run the Composer command to install the latest stable version:
php composer.phar require kiczort/polish-validator-bundle
Add bundle to AppKernel.php
public function registerBundles()
{
$bundles = array(
...
new Kiczort\PolishValidatorBundle\KiczortPolishValidatorBundle(),
...
);
return $bundles;
}
There are PESEL numbers with errors in real word, so in case of this validator checksum checking is only for strict mode. In case of none strict mode it checks length, used chars and correctness of date of birth.
...
// 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;
}
...
// 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;
}
...
// 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;
}
PWZ means "licence to practise a profession" (pl. "prawo wykonywania zawodu"), number given to doctors from NIL (polish Chamber of Physicians and Dentists). Validator accepts also empty strings and nulls so you have to add "Assert/NotBlank" myself.
...
// 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 issues. If you have found bug, please create an issue.
License can be found here.