|
@@ -3,12 +3,12 @@ Inline Validation
|
|
|
|
|
|
The inline validation is about delegating model validation to a dedicated service.
|
|
|
The current validation implementation built in the Symfony2 framework is very powerful
|
|
|
-as it allows to declare validation on : class, field and getter. However these declarations
|
|
|
-can take a while to code for complex rules. Rules must be a set of a ``Constraint``
|
|
|
+as it allows to declare validation on a : class, field and getter. However these declarations
|
|
|
+can take a while to code for complex rules. As rules must be a set of a ``Constraint``
|
|
|
and ``Validator`` instances.
|
|
|
|
|
|
The inline validation tries to provide a nice solution by introducing an ``ErrorElement``
|
|
|
-object. The object can be used to check assertion against the model :
|
|
|
+object. The object can be used to check assertions against the model :
|
|
|
|
|
|
.. code-block:: php
|
|
|
|
|
@@ -43,6 +43,11 @@ object. The object can be used to check assertion against the model :
|
|
|
This solution relies on the validator component so validation defined through
|
|
|
the validator component will be used.
|
|
|
|
|
|
+.. tip::
|
|
|
+
|
|
|
+ You can also use ``$errorElement->addConstraint(new \Symfony\Component\Validator\Constraints\NotBlank())``
|
|
|
+ instead of calling assertNotBlank().
|
|
|
+
|
|
|
Using this validator
|
|
|
--------------------
|
|
|
|