PHPackages                             atournayre/entity-validation - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. atournayre/entity-validation

AbandonedLibrary[Validation &amp; Sanitization](/categories/validation)

atournayre/entity-validation
============================

Entity validation using Symfony Validator

1.1.1(3y ago)01.4kPHPPHP &gt;=8.1

Since Sep 4Pushed 2y ago1 watchersCompare

[ Source](https://github.com/atournayre/entity-validation)[ Packagist](https://packagist.org/packages/atournayre/entity-validation)[ RSS](/packages/atournayre-entity-validation/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (4)Dependencies (4)Versions (5)Used By (0)

Entity Validation Component
===========================

[](#entity-validation-component)

This component helps entity validation, but it also works for DTOs...

Install
-------

[](#install)

### Composer

[](#composer)

```
composer require atournayre/entity-validation
```

Add validation to a class
-------------------------

[](#add-validation-to-a-class)

### Entity / DTO / ...

[](#entity--dto--)

```
namespace App\Entity;

use Atournayre\EntityValidation\ValidableEntityTrait;

class YourEntity implements ValidableEntityInterface
{
    // Your code

    use ValidableEntityTrait;
}
```

### Constraint

[](#constraint)

Create `YourEntityConstraint` (name is important); it has to be located in the same directory of your Entity / DTO ...,

### ConstraintValidator

[](#constraintvalidator)

Create `YourEntityConstraintValidator` (name is important); it has to be located in the same directory of your Entity / DTO ...,

Example
-------

[](#example)

### ConstraintValidator

[](#constraintvalidator-1)

```
