Skip to content

[Validator][RFC] Unique Constraint could have a errorPath parameter #57503

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Crovitche-1623 opened this issue Jun 23, 2024 · 2 comments
Closed
Labels
RFC RFC = Request For Comments (proposals about features that you want to be discussed) Validator

Comments

@Crovitche-1623
Copy link

Crovitche-1623 commented Jun 23, 2024

Description

It could be a great improvement if the Unique Constraint could take a errorPath parameter (like the UniqueEntity constraint) pointing to the field that is a duplicate. This will be even more relevant if this PR is merged.

Example

Using the example provided in the documentation:

<?php
// src/Entity/PointOfInterest.php
namespace App\Entity;

use Symfony\Component\Validator\Constraints as Assert;

class PointOfInterest
{
    #[Assert\Unique(fields: ['latitude', 'longitude'], errorPath: 'latitude')]
    protected array $coordinates;
}
@carsonbot carsonbot added RFC RFC = Request For Comments (proposals about features that you want to be discussed) Validator labels Jun 23, 2024
@norkunas
Copy link
Contributor

Like #57436 ? :)

@Crovitche-1623
Copy link
Author

@norkunas Yes exactly. Thank you for your work, I didn't see your PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC RFC = Request For Comments (proposals about features that you want to be discussed) Validator
Projects
None yet
Development

No branches or pull requests

3 participants