Skip to content

Commit 940b402

Browse files
committed
Debugging the validator constraints
1 parent 4787bba commit 940b402

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

validation.rst

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,81 @@ constraint that's applied to the class itself. When that class is validated,
719719
methods specified by that constraint are simply executed so that each can
720720
provide more custom validation.
721721

722+
Debugging the constraints
723+
-------------------------
724+
725+
The ``debug:validator 'App\Entity\DummyClassOne'`` command lists validation constraints of ``App\Entity\DummyClassOne`` resource.
726+
727+
.. code-block:: terminal
728+
729+
$ php bin/console debug:validator 'App\Entity\DummyClassOne'
730+
731+
App\Entity\DummyClassOne
732+
-----------------------------------------------------
733+
734+
+---------------+--------------------------------------------------+---------+------------------------------------------------------------+
735+
| Property | Name | Groups | Options |
736+
+---------------+--------------------------------------------------+---------+------------------------------------------------------------+
737+
| firstArgument | Symfony\Component\Validator\Constraints\NotBlank | Default | [ |
738+
| | | | "message" => "This value should not be blank.", |
739+
| | | | "allowNull" => false, |
740+
| | | | "normalizer" => null, |
741+
| | | | "payload" => null |
742+
| | | | ] |
743+
| firstArgument | Symfony\Component\Validator\Constraints\Email | Default | [ |
744+
| | | | "message" => "This value is not a valid email address.", |
745+
| | | | "mode" => null, |
746+
| | | | "normalizer" => null, |
747+
| | | | "payload" => null |
748+
| | | | ] |
749+
+---------------+--------------------------------------------------+---------+------------------------------------------------------------+
750+
751+
You can also list validation constraints for all resources of a path.
752+
753+
.. code-block:: terminal
754+
755+
$ php bin/console debug:validator src/Entity
756+
757+
App\Entity\DummyClassOne
758+
------------------------
759+
760+
+---------------+--------------------------------------------------+---------+------------------------------------------------------------+
761+
| Property | Name | Groups | Options |
762+
+---------------+--------------------------------------------------+---------+------------------------------------------------------------+
763+
| firstArgument | Symfony\Component\Validator\Constraints\NotBlank | Default | [ |
764+
| | | | "message" => "This value should not be blank.", |
765+
| | | | "allowNull" => false, |
766+
| | | | "normalizer" => null, |
767+
| | | | "payload" => null |
768+
| | | | ] |
769+
| firstArgument | Symfony\Component\Validator\Constraints\Email | Default | [ |
770+
| | | | "message" => "This value is not a valid email address.", |
771+
| | | | "mode" => null, |
772+
| | | | "normalizer" => null, |
773+
| | | | "payload" => null |
774+
| | | | ] |
775+
+---------------+--------------------------------------------------+---------+------------------------------------------------------------+
776+
777+
App\Entity\DummyClassTwo
778+
------------------------
779+
780+
+---------------+--------------------------------------------------+---------+------------------------------------------------------------+
781+
| Property | Name | Groups | Options |
782+
+---------------+--------------------------------------------------+---------+------------------------------------------------------------+
783+
| firstArgument | Symfony\Component\Validator\Constraints\NotBlank | Default | [ |
784+
| | | | "message" => "This value should not be blank.", |
785+
| | | | "allowNull" => false, |
786+
| | | | "normalizer" => null, |
787+
| | | | "payload" => null |
788+
| | | | ] |
789+
| firstArgument | Symfony\Component\Validator\Constraints\Email | Default | [ |
790+
| | | | "message" => "This value is not a valid email address.", |
791+
| | | | "mode" => null, |
792+
| | | | "normalizer" => null, |
793+
| | | | "payload" => null |
794+
| | | | ] |
795+
+---------------+--------------------------------------------------+---------+------------------------------------------------------------+
796+
722797
Final Thoughts
723798
--------------
724799

0 commit comments

Comments
 (0)