|
| 1 | +Symfony2 bundle with Polish validators |
| 2 | +================================== |
| 3 | + |
| 4 | +[](https://packagist.org/packages/kiczort/polish-validator-bundle) |
| 5 | +[](https://packagist.org/packages/kiczort/polish-validator-bundle) |
| 6 | +[](http://travis-ci.org/kiczort/polish-validator-bundle) |
| 7 | +[](https://scrutinizer-ci.com/g/kiczort/polish-validator-bundle/) |
| 8 | + |
| 9 | +This is Symfony2 bundle with validators for Polish identification numbers like: PESEL, NIP, REGON. |
| 10 | + |
| 11 | + |
| 12 | +# Installation |
| 13 | + |
| 14 | +The recommended way to install this library is |
| 15 | +[Composer](http://getcomposer.org). |
| 16 | + |
| 17 | +```bash |
| 18 | +# Install Composer |
| 19 | +curl -sS https://getcomposer.org/installer | php |
| 20 | +``` |
| 21 | + |
| 22 | +Next, run the Composer command to install the latest stable version: |
| 23 | + |
| 24 | +```bash |
| 25 | +php composer.phar require kiczort/polish-validator-bundle |
| 26 | +``` |
| 27 | + |
| 28 | +Add bundle to AppKernel.php |
| 29 | + |
| 30 | +```php |
| 31 | + public function registerBundles() |
| 32 | + { |
| 33 | + $bundles = array( |
| 34 | + ... |
| 35 | + new Kiczort\PolishValidatorBundle\KiczortPolishValidatorBundle(), |
| 36 | + ... |
| 37 | + ); |
| 38 | + |
| 39 | + return $bundles; |
| 40 | + } |
| 41 | +``` |
| 42 | + |
| 43 | +# Documentation |
| 44 | + |
| 45 | +## Example of use PeselValidator: |
| 46 | + |
| 47 | +There are PESEL numbers with errors in real word, so in case of this validator checksum checking is only for strict mode. |
| 48 | +In case of none strict mode it checks length, used chars and correctness of date of birth. |
| 49 | + |
| 50 | +```php |
| 51 | +... |
| 52 | +// src/AppBundle/Entity/Person.php |
| 53 | +namespace AppBundle\Entity; |
| 54 | + |
| 55 | +use KiczortPolishValidatorBundle\Validator\Constraints as KiczortAssert; |
| 56 | + |
| 57 | +class Person |
| 58 | +{ |
| 59 | + /** |
| 60 | + * @KiczortAssert\Pesel( |
| 61 | + * message = "The '{{ value }}' is not a valid PESEL number.", |
| 62 | + * strict = true |
| 63 | + * ) |
| 64 | + */ |
| 65 | + protected $pesel; |
| 66 | +} |
| 67 | +``` |
| 68 | + |
| 69 | +## Example of use NipValidator: |
| 70 | + |
| 71 | +```php |
| 72 | +... |
| 73 | +// src/AppBundle/Entity/Person.php |
| 74 | +namespace AppBundle\Entity; |
| 75 | + |
| 76 | +use KiczortPolishValidatorBundle\Validator\Constraints as KiczortAssert; |
| 77 | + |
| 78 | +class Person |
| 79 | +{ |
| 80 | + /** |
| 81 | + * @KiczortAssert\Nip |
| 82 | + */ |
| 83 | + protected $nip; |
| 84 | +} |
| 85 | +``` |
| 86 | + |
| 87 | +## Example of use RegonValidator: |
| 88 | + |
| 89 | +```php |
| 90 | +... |
| 91 | +// src/AppBundle/Entity/Company.php |
| 92 | +namespace AppBundle\Entity; |
| 93 | + |
| 94 | +use KiczortPolishValidatorBundle\Validator\Constraints as KiczortAssert; |
| 95 | + |
| 96 | +class Company |
| 97 | +{ |
| 98 | + /** |
| 99 | + * @KiczortAssert\Regon |
| 100 | + */ |
| 101 | + protected $regon; |
| 102 | +} |
| 103 | +``` |
| 104 | + |
| 105 | +# Bug tracking |
| 106 | + |
| 107 | +[GitHub issues](https://github.com/kiczort/polish-validator-bundle/issues). |
| 108 | +If you have found bug, please create an issue. |
| 109 | + |
| 110 | + |
| 111 | +# MIT License |
| 112 | + |
| 113 | +License can be found [here](https://github.com/kiczort/polish-validator-bundle/blob/master/LICENSE). |
| 114 | + |
0 commit comments