Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Closed
@Crovitche-1623

Description

@Crovitche-1623

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCRFC = Request For Comments (proposals about features that you want to be discussed)Validator

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions