Category: validation

Syfmony custom validator based on other Constraints

How can one write a custom validator? For example, I have this working code: use SymfonyComponentValidatorConstraints as Assert; use SymfonyComponentValidatorConstraintViolationInterface; use SymfonyComponentValidatorValidation; $input = [ null, //fail 0, //fail 1, //fail 2, //fail "12", //ok – string can be (at…

Symfony – awkward Password Length violation on partial User entity update through a form containing no password field

In Symfony 5.1 project I have a form that indents to partially update User entity records (some fields except of the password and email). The form is generated with a FormBuilder class – a sub-class that extends UserType class, with…

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…