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

1.0.0 2025-10-17 07:04 UTC

This package is auto-updated.

Last update: 2025-10-17 07:14:01 UTC


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' ]