Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Validator] Allow validating every class against unique entity constraint#14458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
wkania wants to merge1 commit intosymfony:7.1
base:7.1
Choose a base branch
Loading
fromwkania:patch-2

Conversation

wkania
Copy link
Contributor

@wkaniawkania commentedOct 21, 2020
edited
Loading

Done

@javiereguiluzjaviereguiluz added the Waiting Code MergeDocs for features pending to be merged labelOct 22, 2020
@xabbuhxabbuh added this to thenext milestoneOct 22, 2020
@wkaniawkania changed the title[WIP][DoctrineBridge] Allow validating every class against unique ent…[DoctrineBridge] Allow validating every class against unique entity constraintNov 1, 2020
@wkaniawkania changed the base branch from5.4 to7.1February 12, 2024 21:23
fabpot added a commit to symfony/symfony that referenced this pull requestMay 2, 2024
…ss against unique entity constraint (wkania)This PR was merged into the 7.1 branch.Discussion----------[DoctrineBridge][Validator] Allow validating every class against unique entity constraint| Q             | A| ------------- | ---| Branch?       | 7.x <!-- see below -->| Bug fix?      | no| New feature?  | yes <!-- pleasedate src/**/CHANGELOG.md files -->| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tickets       |Fix#22592| License       | MIT| Doc PR        |symfony/symfony-docs#14458 <!-- required for new features -->Yet another try to allow validating every class against unique entity constraint.Based on the knowledge from issue#22592 and pull request#24974.This constraint doesn’t provide any protection against race conditions, which is enough in most cases. You can always try-catch flush method. Let's not talk about this problem.Current state:- can be applied only to an entity,- support entity inheritance,- can validate unique combinations of multiple fields,- meaningful errors related to entities,- is valid during an update, when the only matched entity is the same as the entity being validatedNew state:- preserve the current state,- all old tests pass (no changes in them),- no breaking changes,- can be applied to any class (like DTO),- can map object fields to entity fields (optional),- when the object update some entity, there is an option to provide the identifier field names to match that entity (optional)Examples:1. DTO adds a new entity.```namespace App\Message;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;/** * `@UniqueEntity`(fields={"name"}, entityClass="App\Entity\User") */class HireAnEmployee{    public $name;    public function __construct($name)    {        $this->name = $name;    }}```2. DTO adds a new entity, but the name of the field in the entity is different.```namespace App\Message;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;/** * `@UniqueEntity`(fields={"name": "username"}, entityClass="App\Entity\User") */class HireAnEmployee{    public $name;    public function __construct($name)    {        $this->name = $name;    }}```3. DTO updates an entity.```namespace App\Message;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;/** * `@UniqueEntity`(fields={"name"}, entityClass="App\Entity\User", identifierFieldNames={"uid": "id"}) */class UpdateEmployeeProfile{    public $uid;    public $name;    public function __construct($uid, $name)    {        $this->uid = $uid;        $this->name = $name;    }}```Commits-------adb9afa [DoctrineBridge][Validator] Allow validating every class against unique entity constraint
symfony-splitter pushed a commit to symfony/doctrine-bridge that referenced this pull requestMay 2, 2024
…ss against unique entity constraint (wkania)This PR was merged into the 7.1 branch.Discussion----------[DoctrineBridge][Validator] Allow validating every class against unique entity constraint| Q             | A| ------------- | ---| Branch?       | 7.x <!-- see below -->| Bug fix?      | no| New feature?  | yes <!-- pleasedate src/**/CHANGELOG.md files -->| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tickets       | Fix #22592| License       | MIT| Doc PR        |symfony/symfony-docs#14458 <!-- required for new features -->Yet another try to allow validating every class against unique entity constraint.Based on the knowledge from issuesymfony/symfony#22592 and pull requestsymfony/symfony#24974.This constraint doesn’t provide any protection against race conditions, which is enough in most cases. You can always try-catch flush method. Let's not talk about this problem.Current state:- can be applied only to an entity,- support entity inheritance,- can validate unique combinations of multiple fields,- meaningful errors related to entities,- is valid during an update, when the only matched entity is the same as the entity being validatedNew state:- preserve the current state,- all old tests pass (no changes in them),- no breaking changes,- can be applied to any class (like DTO),- can map object fields to entity fields (optional),- when the object update some entity, there is an option to provide the identifier field names to match that entity (optional)Examples:1. DTO adds a new entity.```namespace App\Message;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;/** * `@UniqueEntity`(fields={"name"}, entityClass="App\Entity\User") */class HireAnEmployee{    public $name;    public function __construct($name)    {        $this->name = $name;    }}```2. DTO adds a new entity, but the name of the field in the entity is different.```namespace App\Message;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;/** * `@UniqueEntity`(fields={"name": "username"}, entityClass="App\Entity\User") */class HireAnEmployee{    public $name;    public function __construct($name)    {        $this->name = $name;    }}```3. DTO updates an entity.```namespace App\Message;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;/** * `@UniqueEntity`(fields={"name"}, entityClass="App\Entity\User", identifierFieldNames={"uid": "id"}) */class UpdateEmployeeProfile{    public $uid;    public $name;    public function __construct($uid, $name)    {        $this->uid = $uid;        $this->name = $name;    }}```Commits-------adb9afa4a5 [DoctrineBridge][Validator] Allow validating every class against unique entity constraint
@javiereguiluzjaviereguiluz removed the Waiting Code MergeDocs for features pending to be merged labelMay 3, 2024
@carsonbotcarsonbot changed the title[DoctrineBridge] Allow validating every class against unique entity constraintAllow validating every class against unique entity constraintMay 3, 2024
@wkaniawkania changed the titleAllow validating every class against unique entity constraint[Validator] Allow validating every class against unique entity constraintAug 11, 2024
@wkania
Copy link
ContributorAuthor

@xabbuh could you please review this PR? Thx

@bigfoot90
Copy link

bigfoot90 commentedOct 19, 2024
edited
Loading

Any news on this? ♥

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@HeahDudeHeahDudeAwaiting requested review from HeahDude

@xabbuhxabbuhAwaiting requested review from xabbuhxabbuh is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
next
Development

Successfully merging this pull request may close these issues.

5 participants
@wkania@bigfoot90@javiereguiluz@xabbuh@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp