purpledot/validation-bundle

1.0.1 2025-04-04 10:21 UTC

This package is auto-updated.

Last update: 2025-05-04 10:32:34 UTC


README

Additional validators set for Symfony.

Installation

From the command line run

$ composer require purpledot/validation-bundle

Validators

PolishIdCardNumber

Checks if the value is a valid Polish ID number.

Example usage

use PurpleDot\ValidationBundle\Validator\Constraints as PurpleDotAssert;

// ...

#[PurpleDotAssert\PolishIdCardNumber]
private ?string $idCardNUmber = null;

PolishMobilePhone

Checks if the value is a valid Polish mobile phone number.

Example usage

use PurpleDot\ValidationBundle\Validator\Constraints as PurpleDotAssert;

// ...

#[PurpleDotAssert\PolishMobilePhone]
private ?string $phoneNumber;

PolishTaxNumber

Checks if the value is a valid Polish tax number (NIP).

Parameter Type Default Description
requirePrefix bool false Enable/disable tax number prefix requirement
allowPrefix bool true Enable/Disable ability to provide a tax number prefix

Example usage

use PurpleDot\ValidationBundle\Validator\Constraints as PurpleDotAssert;

// ...

#[PurpleDotAssert\PolishTaxNumber]
private ?string $taxNumber;

$this->taxNumber = 'PL7746249830' // valid
$this->taxNumber = '7746249830' // valid 

Require tax number prefix

use PurpleDot\ValidationBundle\Validator\Constraints as PurpleDotAssert;

// ...

#[PurpleDotAssert\PolishTaxNumber(requirePrefix: true)]
private ?string $taxNumber;

$this->taxNumber = 'PL7746249830' // valid
$this->taxNumber = '7746249830' // invalid 

Disallow tax number prefix

use PurpleDot\ValidationBundle\Validator\Constraints as PurpleDotAssert;

// ...

#[PurpleDotAssert\PolishTaxNumber(allowPrefix: false)]
private ?string $taxNumber;

$this->taxNumber = '7746249830' // valid 
$this->taxNumber = 'PL7746249830' // invalid

Pesel

Checks if the value is a valid PESEL number.

Example usage

use PurpleDot\ValidationBundle\Validator\Constraints as PurpleDotAssert;

// ...

#[PurpleDotAssert\Pesel]
private ?string $pesel = null;