@@ -459,9 +459,15 @@ Before using validation, add support for it in your application:
459
459
460
460
$ composer require symfony/validator
461
461
462
- Validation is done by adding a set of rules (called constraints) to a class. To
463
- see this in action, add validation constraints so that the ``task `` field cannot
464
- be empty and the ``dueDate `` field cannot be empty and must be a valid \D ateTime
462
+ Validation is done by adding a set of rules, called (validation) constraints,
463
+ to a class.
464
+
465
+ There are two approaches - you can either add the constraints to the entity,
466
+ or you can add the constraints to the form.
467
+
468
+ To see the first approach - adding constraints to the entity - in action,
469
+ add the validation constraints, so that the ``task `` field cannot be empty,
470
+ and the ``dueDate `` field cannot be empty, and must be a valid \D ateTime
465
471
object.
466
472
467
473
.. configuration-block ::
@@ -544,9 +550,11 @@ object.
544
550
}
545
551
546
552
That's it! If you re-submit the form with invalid data, you'll see the
547
- corresponding errors printed out with the form. Read the
548
- :doc: `Symfony validation documentation </validation >` to learn more about this
549
- powerful feature.
553
+ corresponding errors printed out with the form.
554
+
555
+ To see the second approach - adding constraints to the form and to
556
+ learn more about the validation constraints, please refer to the
557
+ :doc: `Symfony validation documentation </validation >`.
550
558
551
559
Other Common Form Features
552
560
--------------------------
0 commit comments