@@ -807,10 +807,11 @@ user registers and when a user updates their contact information later:
807
807
}
808
808
}
809
809
810
- With this configuration, there are two validation groups:
810
+ With this configuration, there are three validation groups:
811
811
812
- * ``User `` - contains the constraints that belong to no other group,
813
- and is considered the ``Default `` group. (This group is useful for
812
+ * ``User `` - contains the constraints that belong to no other group;
813
+
814
+ * ``Default `` - equivalent to the ``User `` group (This group is useful for
814
815
:ref: `book-validation-group-sequence `);
815
816
816
817
* ``registration `` - contains the constraints on the ``email `` and ``password ``
@@ -837,13 +838,8 @@ Group Sequence
837
838
--------------
838
839
839
840
In some cases, you want to validate your groups by steps. To do this, you can
840
- use the ``GroupSequence `` feature. In the case, an object defines a group sequence,
841
- and then the groups in the group sequence are validated in order.
842
-
843
- .. tip ::
844
-
845
- Group sequences cannot contain the group ``Default ``, as this would create
846
- a loop. Instead, use the group ``{ClassName} `` (e.g. ``User ``).
841
+ use the ``GroupSequence `` feature. In this case, an object defines a group sequence
842
+ , which determines the order groups should be validated.
847
843
848
844
For example, suppose you have a ``User `` class and want to validate that the
849
845
username and the password are different only if all other validation passes
@@ -968,6 +964,20 @@ In this example, it will first validate all constraints in the group ``User``
968
964
(which is the same as the ``Default `` group). Only if all constraints in
969
965
that group are valid, the second group, ``Strict ``, will be validated.
970
966
967
+ .. caution ::
968
+
969
+ As you have already seen in the previous section, the ``Default `` group
970
+ and the group containing the class name (e.g. ``User ``) were identical.
971
+ However, when using Group Sequences, they are no longer identical. The
972
+ ``Default `` group will now reference the group sequence, instead of all
973
+ constraints that do not belong to any group.
974
+
975
+ This means that you have to use the ``{ClassName} `` (e.g. ``User ``) group
976
+ when specifing a group sequence. When using ``Default ``, you get an
977
+ infinite recursion (as the ``Default `` groups references the group
978
+ sequence, which will contain the ``Default `` group which references the
979
+ same group sequence, ...).
980
+
971
981
Group Sequence Providers
972
982
~~~~~~~~~~~~~~~~~~~~~~~~
973
983
0 commit comments