{"id":20622302,"url":"https://github.com/k2gl/entity-exist","last_synced_at":"2026-04-21T14:31:45.507Z","repository":{"id":61782465,"uuid":"555064999","full_name":"k2gl/entity-exist","owner":"k2gl","description":"Checks if there is at least one row with the required field in the database, for example, a row with the same identifier","archived":false,"fork":false,"pushed_at":"2024-04-21T16:29:35.000Z","size":71,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-17T05:29:22.463Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/k2gl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-20T22:20:47.000Z","updated_at":"2024-04-21T16:28:04.000Z","dependencies_parsed_at":"2024-03-01T05:32:58.730Z","dependency_job_id":"dd7dff0b-e090-4abe-9407-fa747cf1303b","html_url":"https://github.com/k2gl/entity-exist","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"ac663d8e258e0d008690f194845a583e85e2661d"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k2gl%2Fentity-exist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k2gl%2Fentity-exist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k2gl%2Fentity-exist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k2gl%2Fentity-exist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/k2gl","download_url":"https://codeload.github.com/k2gl/entity-exist/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242300250,"owners_count":20105178,"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":[],"created_at":"2024-11-16T12:22:03.933Z","updated_at":"2026-04-21T14:31:40.453Z","avatar_url":"https://github.com/k2gl.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Assert entity exist or not using Symfony constraints and Doctrine.\n\n[![GitHub Actions](https://github.com/k2gl/entity-exist/workflows/CI/badge.svg)](https://github.com/k2gl/entity-exist/actions?workflow=CI)\n\n## Installation\n\nYou can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):\n\n```\ncomposer require k2gl/entity-exist\n```\n\n## Configuration\n\nMakes classes in src/ available to be used as services in **services.yaml**\n\n```\nservices:\n    K2gl\\Component\\Validator\\Constraint\\EntityExist\\:\n        resource: '../vendor/k2gl/entity-exist/src/'\n        arguments: ['@doctrine.orm.entity_manager']\n        tags:\n            - { name: validator.constraint_validator }\n```\n\n## Usage\n\n### AssertEntityNotExist\n\n```php\nuse K2gl\\Component\\Validator\\Constraint\\EntityExist\\AssertEntityNotExist;\n\nreadonly class RegisterUserOrder\n{\n    public function __construct(\n        #[Assert\\NotBlank]\n        #[Assert\\Email]\n        #[AssertEntityNotExist(\n            entity: User::class,\n            property: 'email',\n            message: 'User with email \"%value%\" already registered.'\n        )]\n        public string $email,\n    ) {\n    }\n}\n```\n\n### AssertEntityExist\n\n```php\nuse K2gl\\Component\\Validator\\Constraint\\EntityExist\\AssertEntityExist;\n\nreadonly class TransferUserToOtherUnitOrder\n{\n    public function __construct(\n        #[Assert\\NotBlank]\n        #[AssertEntityExist(\n            entity: User::class,\n            property: 'uuid',\n        )]\n        public string $user,\n        #[Assert\\NotBlank]\n        #[AssertEntityExist(\n            entity: Unit::class,\n            property: 'uuid',\n        )]\n        public string $unit,        \n    ) {\n    }\n}\n```\n\n## Pull requests are always welcome\n[Collaborate with pull requests](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk2gl%2Fentity-exist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk2gl%2Fentity-exist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk2gl%2Fentity-exist/lists"}