{"id":15025851,"url":"https://github.com/rdey/entity-exists-validation-constraint","last_synced_at":"2025-10-03T23:32:22.456Z","repository":{"id":46173803,"uuid":"515163064","full_name":"rdey/entity-exists-validation-constraint","owner":"rdey","description":null,"archived":false,"fork":true,"pushed_at":"2022-07-18T12:21:55.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-09-29T19:41:47.848Z","etag":null,"topics":["lib","php72","php73","php74","php80","php81","php82","sf63"],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"Happyr/entity-exists-validation-constraint","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rdey.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["Nyholm"]}},"created_at":"2022-07-18T11:52:24.000Z","updated_at":"2023-01-10T13:01:55.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/rdey/entity-exists-validation-constraint","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdey%2Fentity-exists-validation-constraint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdey%2Fentity-exists-validation-constraint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdey%2Fentity-exists-validation-constraint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdey%2Fentity-exists-validation-constraint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rdey","download_url":"https://codeload.github.com/rdey/entity-exists-validation-constraint/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235204448,"owners_count":18952326,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lib","php72","php73","php74","php80","php81","php82","sf63"],"created_at":"2024-09-24T20:03:09.758Z","updated_at":"2025-10-03T23:32:22.108Z","avatar_url":"https://github.com/rdey.png","language":null,"funding_links":["https://github.com/sponsors/Nyholm"],"categories":[],"sub_categories":[],"readme":"# Symfony validator for Entity Exist\n\n[![Latest Version](https://img.shields.io/github/release/happyr/entity-exists-validation-constraint.svg?style=flat-square)](https://github.com/happyr/entity-exists-validation-constraint/releases)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n[![Build Status](https://img.shields.io/travis/happyr/entity-exists-validation-constraint.svg?style=flat-square)](https://travis-ci.org/happyr/entity-exists-validation-constraint)\n[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/happyr/entity-exists-validation-constraint.svg?style=flat-square)](https://scrutinizer-ci.com/g/happyr/entity-exists-validation-constraint)\n[![Quality Score](https://img.shields.io/scrutinizer/g/happyr/entity-exists-validation-constraint.svg?style=flat-square)](https://scrutinizer-ci.com/g/happyr/entity-exists-validation-constraint)\n[![Total Downloads](https://img.shields.io/packagist/dt/happyr/entity-exists-validation-constraint.svg?style=flat-square)](https://packagist.org/packages/happyr/entity-exists-validation-constraint)\n\nA small validator that verifies that an Entity actually exists. This is especially useful if you use Symfony Messenger\ncomponent. Now you can safely validate the message and put it on a queue for processing later.\n\n\n```php\nnamespace App\\Message\\Command;\n\nuse Happyr\\Validator\\Constraint\\EntityExist;\nuse Symfony\\Component\\Validator\\Constraints as Assert;\n\nfinal class EmailUser\n{\n    /**\n     * @Assert\\NotBlank\n     * @EntityExist(entity=\"App\\Entity\\User\")\n     *\n     * @var int User's id property\n     */\n    private $user;\n\n    /**\n     * @Assert\\NotBlank\n     * @EntityExist(entity=\"App\\Entity\\Other\", property=\"name\")\n     *\n     * @var string The name of \"Other\". We use its \"name\" property. \n     */\n    private $other;\n\n    // ...\n```\n\nIn case you are using other constraints to validate the property before entity should be checked in the database (like `@Assert\\Uuid`) you should use [Group sequence](https://symfony.com/doc/current/validation/sequence_provider.html) in order to avoid 500 errors from Doctrine mapping.\n\n```php\nnamespace App\\Message\\Command;\n\nuse Happyr\\Validator\\Constraint\\EntityExist;\nuse Symfony\\Component\\Validator\\Constraints as Assert;\n\n/**\n * @Assert\\GroupSequence({\"EmailUser\", \"DatabaseCall\"})\n */\nfinal class EmailUser\n{\n    /**\n     * @Assert\\NotBlank\n     * @Assert\\Uuid\n     * @EntityExist(entity=\"App\\Entity\\User\", groups={\"DatabaseCall\"}, property=\"uuid\")\n     *\n     * @var string Uuid\n     */\n    private $user;\n\n    // ...\n```\n\n## Install\n\n```console\ncomposer require happyr/entity-exists-validation-constraint\n\n```\n\nThen register the services with:\n\n```yaml\n# config/packages/happyr_entity_exists_validator.yaml\nservices:\n  Happyr\\Validator\\Constraint\\EntityExistValidator:\n    arguments: ['@doctrine.orm.entity_manager']\n    tags: [ 'validator.constraint_validator' ]\n```\n\n## Note\n\nThe Validator will not produce a violation when value is empty. This means that you should most likely use it in\ncombination with `NotBlank`. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frdey%2Fentity-exists-validation-constraint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frdey%2Fentity-exists-validation-constraint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frdey%2Fentity-exists-validation-constraint/lists"}