dayploy / entity-does-not-exists-validation-constraint
Verify that your entity does not exists
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/dayploy/entity-does-not-exists-validation-constraint
Requires
- php: ^8.1
- doctrine/orm: ^2.4 || ^3.0
- symfony/validator: ^6.0 || ^7.0
Requires (Dev)
- symfony/phpunit-bridge: ^6.0
- symfony/validator: ^6.4 || ^7.0
README
A validator that verifies that an Entity actually does not exists. This is useful if the client of your api provides the ID to create an entity. You do not want an ID collision.
namespace App\Message\Command; use Dayploy\Validator\Constraint\EntityDoesNotExist; use Symfony\Component\Validator\Constraints as Assert; final class CreateUser { #[EntityDoesNotExist(entity: User::class, property: 'id')] private Uuid $id; // ...
Install
composer require dayploy/entity-does-not-exists-validation-constraint
Then register the services with:
# config/packages/dayploy_entity_does_not_exists_validator.yaml services: Dayploy\Validator\Constraint\EntityDoesNotExistValidator: arguments: ['@doctrine.orm.entity_manager'] tags: [ 'validator.constraint_validator' ]