Fixed: [saved exports] Transform null strings into blank strings, and add validation

This commit is contained in:
Julien Fastré 2022-11-16 14:56:42 +01:00
parent 00bf7bf299
commit 15871db7fd
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB

View File

@ -18,6 +18,7 @@ use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Uuid; use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface; use Ramsey\Uuid\UuidInterface;
use Symfony\Component\Validator\Constraints as Assert;
/** /**
* @ORM\Entity * @ORM\Entity
@ -31,6 +32,7 @@ class SavedExport implements TrackCreationInterface, TrackUpdateInterface
/** /**
* @ORM\Column(type="text", nullable=false, options={"default": ""}) * @ORM\Column(type="text", nullable=false, options={"default": ""})
* @Assert\NotBlank
*/ */
private string $description = ''; private string $description = '';
@ -53,6 +55,7 @@ class SavedExport implements TrackCreationInterface, TrackUpdateInterface
/** /**
* @ORM\Column(type="text", nullable=false, options={"default": ""}) * @ORM\Column(type="text", nullable=false, options={"default": ""})
* @Assert\NotBlank
*/ */
private string $title = ''; private string $title = '';
@ -96,9 +99,9 @@ class SavedExport implements TrackCreationInterface, TrackUpdateInterface
return $this->user; return $this->user;
} }
public function setDescription(string $description): SavedExport public function setDescription(?string $description): SavedExport
{ {
$this->description = $description; $this->description = (string) $description;
return $this; return $this;
} }
@ -117,9 +120,9 @@ class SavedExport implements TrackCreationInterface, TrackUpdateInterface
return $this; return $this;
} }
public function setTitle(string $title): SavedExport public function setTitle(?string $title): SavedExport
{ {
$this->title = $title; $this->title = (string) $title;
return $this; return $this;
} }