Category: validation

Multiple file validation: "This value should be of type string"

I’m trying to use Symfony Validator on a file upload form (form extension’s validation) and I’m getting this error message: messageTemplate: “This value should be of type string.” from SymfonyComponentValidatorConstraintViolation Upload works well without the validator, and I cant figure…

Symfony – Validation form errors messages are not like my constraints entity

I have defined Constraints in my Entity as the documentation said like this example bellow : /** * @ORMColumn(type=”float”, nullable=true) * @AssertType(type={“float”, “integer”}, message=”Budget have to be a number”) */ private $budget; /** * @ORMColumn(type=”string”, length=255) * @AssertNotNull */ private…

Symfony : embeded subform and createdAt / updatedAt : validation conflict

I have an entity form that embed a collectionType and subforms. In order to make the required option work, I had to enable Auto_mapping class ClassePriceType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add(‘priceform’, PriceformType::class, […

Entity with DateTime won’t validate (no Form) [duplicate]

I have an Entity with the following annotations /** * @ORMColumn(type=”utcdatetime”) * @AssertDateTime() * @var DateTime */ private $approvedDate; The constructor in the entity sets the value as a DateTime object: public function __construct() { $utcTZ = new DateTimeZone(‘UTC’); $this->approvedDate…

Symfony 5 Constraint Validation : Customize error message

I want to use the new NotCompromisedPassword released on SF 4.3 : https://symfony.com/blog/new-in-symfony-4-3-compromised-password-validator I’ve set it up on my validation.yaml like this : AppEntityUser: constraints: – AppValidatorConstraintsConstraintPassword: ~ properties: plainPassword: – SymfonyComponentValidatorConstraintsNotCompromisedPassword: ~ It works, but i want to customize…

symfony form field’s required (*) flag ignores validation groups

I’m using entity @Assert annotations with different groups tags. /** * @var string * @AssertNotBlank(groups={“basic”}) * @ORMColumn(name=”name”, type=”string”, length=255, nullable=true) */ private $name = null; /** * @var string * @AssertNotBlank(groups={“advanced”}) * @ORMColumn(name=”full_name”, type=”string”, length=255, nullable=true) */ private $fullName =…