fix validation for notification

This commit is contained in:
2022-01-19 13:57:21 +01:00
parent 8133dd7385
commit 2ff34688bb
3 changed files with 14 additions and 4 deletions

View File

@@ -17,6 +17,7 @@ use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity
@@ -32,6 +33,7 @@ class Notification implements TrackUpdateInterface
/**
* @ORM\ManyToMany(targetEntity=User::class)
* @ORM\JoinTable(name="chill_main_notification_addresses_user")
* @Assert\Count(min="1", minMessage="notification.At least one addressee")
*/
private Collection $addressees;
@@ -80,6 +82,7 @@ class Notification implements TrackUpdateInterface
/**
* @ORM\Column(type="text", options={"default": ""})
* @Assert\NotBlank(message="notification.Title must be defined")
*/
private string $title = '';
@@ -286,9 +289,9 @@ class Notification implements TrackUpdateInterface
return $this;
}
public function setMessage(string $message): self
public function setMessage(?string $message): self
{
$this->message = $message;
$this->message = (string) $message;
return $this;
}
@@ -314,9 +317,9 @@ class Notification implements TrackUpdateInterface
return $this;
}
public function setTitle(string $title): Notification
public function setTitle(?string $title): Notification
{
$this->title = $title;
$this->title = (string) $title;
return $this;
}