mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-01 10:59:45 +00:00
Remove empty PersonIdentifier
values during denormalization and add isEmpty
logic to PersonIdentifierWorker
. Include tests for empty value handling.
This commit is contained in:
@@ -38,4 +38,9 @@ final readonly class StringIdentifier implements PersonIdentifierEngineInterface
|
||||
{
|
||||
return $identifier?->getValue()['content'] ?? '';
|
||||
}
|
||||
|
||||
public function isEmpty(PersonIdentifier $identifier): bool
|
||||
{
|
||||
return '' !== trim($identifier->getValue()['content'] ?? '');
|
||||
}
|
||||
}
|
||||
|
@@ -24,4 +24,12 @@ interface PersonIdentifierEngineInterface
|
||||
public function buildForm(FormBuilderInterface $builder, PersonIdentifierDefinition $personIdentifierDefinition): void;
|
||||
|
||||
public function renderAsString(?PersonIdentifier $identifier, PersonIdentifierDefinition $definition): string;
|
||||
|
||||
/**
|
||||
* Return true if the identifier must be considered as empty.
|
||||
*
|
||||
* This is in use when the identifier is validated and must be required. If the identifier is empty and is required
|
||||
* by the definition, the validation will fails.
|
||||
*/
|
||||
public function isEmpty(PersonIdentifier $identifier): bool;
|
||||
}
|
||||
|
@@ -46,4 +46,12 @@ final readonly class PersonIdentifierWorker
|
||||
{
|
||||
return $this->identifierEngine->renderAsString($identifier, $this->definition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the identifier must be considered as empty.
|
||||
*/
|
||||
public function isEmpty(PersonIdentifier $identifier): bool
|
||||
{
|
||||
return $this->identifierEngine->isEmpty($identifier);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user