fixes person resources

This commit is contained in:
2022-01-26 17:53:09 +01:00
parent 6e554e74ab
commit dc0fae7549
9 changed files with 81 additions and 89 deletions

View File

@@ -55,7 +55,7 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
* @ORM\Column(type="text", nullable=true)
* @Groups({"read"})
*/
private $freeText;
private ?string $freeText = null;
/**
* @ORM\Id
@@ -204,6 +204,10 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
$this->setThirdParty(null);
}
if ('' === $freeText) {
$this->freeText = null;
}
return $this;
}
@@ -266,9 +270,8 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
*/
public function validate(ExecutionContextInterface $context, $payload)
{
if (null === $this->person && null === $this->thirdParty && null === $this->freeText) {
if (null === $this->person && null === $this->thirdParty && (null === $this->freeText || '' === $this->freeText)) {
$context->buildViolation('You must associate at least one entity')
->atPath('person')
->addViolation();
}
}