how to add @Assert
in an entity in sf 6 ?
I have tried this
use Symfony\Component\Validator\Constraints as Assert;
and
#[ORM\Column(length=255)]
/*@Assert\NotBlank()*/
private ?string $nom;
CodePudding user response:
You should keep the following use
use Symfony\Component\Validator\Constraints as Assert;
Since PHP 8.0 you should use the attributes
#[ORM\Column(length=255)]
#[Assert\NotBlank]
private ?string $nom;
Only legacy PHP versions (<= 7.4) still need annotations
/**
* @ORM\Column(length=255)
* @Assert\NotBlank
*/
private ?string $nom;