is a constraint ? $5- Basic validation example $6- Supported constraints $7- The validator service $8- Validation and Forms $9- Translation constraint messages $10- Constraint targets $11- Validation groups $12- Validating values $13- How to create a custom validation constraint ? Summary $0
2. Data entered in forms needs to be validated. 3. Data also needs to be validated before it is written into a database or passed to a web service. Why ? $1
rules) of a class and verify whether or not the data on the object satisfies those constraints. The job of the validator: If validation fails, an array of errors is returned.
violation), is represented by a ConstraintViolation object. ConstraintViolation: http://api.symfony.com/2.0/Symfony/Component/Validator/ConstraintViolation.html
validate private, protected or public properties. The example below shows you how to configure the $firstName property of an Author class to have at least 3 characters:
the return value of a method. Validator service allows you to add a constraint to any public method whose name starts with “get” or “is”. In this guide, both of these types of methods are referred to as “getters”.
being validated. For example, the Callback constraint is a generic constraint that's applied to the class itself. When that class is validated, methods specified by that constraint are simply executed so that each can provide more custom validation.
groups: default: contains the constraints not assigned to any other group; registration: contains the constraints on the email and password fields only.
values $12 Import constraint Email Import constraint Email Create the consraint Create the consraint Assigned the error message Assigned the error message Execute Execute Check for errors Check for errors