mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-11-09 21:58:28 +00:00
Handle identifier uniqueness validation for same Person in UniqueIdentifierConstraintValidator
- Add logic to skip validation errors for duplicate identifiers belonging to the same Person. - Update test case to verify no violation is raised for such duplicates. - Refactor repository query logic to support the new validation scenario.
This commit is contained in:
@@ -39,12 +39,15 @@ class UniqueIdentifierConstraintValidator extends ConstraintValidator
|
||||
$identifiers = $this->personIdentifierRepository->findByDefinitionAndCanonical($value->getDefinition(), $value->getValue());
|
||||
|
||||
if (count($identifiers) > 0) {
|
||||
$persons = array_map(fn (PersonIdentifier $idf): string => $this->personRender->renderString($idf->getPerson(), []), $identifiers);
|
||||
if (count($identifiers) > 1 || $identifiers[0]->getPerson() !== $value->getPerson()) {
|
||||
$persons = array_map(fn (PersonIdentifier $idf): string => $this->personRender->renderString($idf->getPerson(), []), $identifiers);
|
||||
|
||||
$this->context->buildViolation($constraint->message)
|
||||
->setParameter('{{ persons }}', implode(', ', $persons))
|
||||
->setParameter('definition_id', (string) $value->getDefinition()->getId())
|
||||
->addViolation();
|
||||
$this->context->buildViolation($constraint->message)
|
||||
->setParameter('{{ persons }}', implode(', ', $persons))
|
||||
->setParameter('definition_id', (string) $value->getDefinition()->getId())
|
||||
->addViolation();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user