Skip to content

Commit 9551424

Browse files
arthrujacobtylerwalls
authored andcommitted
Fixed #37116 -- Explained why a code is useful in a ValidationError.
1 parent 0325492 commit 9551424

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

docs/ref/forms/validation.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ Raising ``ValidationError``
117117
In order to make error messages flexible and easy to override, consider the
118118
following guidelines:
119119

120-
* Provide a descriptive error ``code`` to the constructor::
120+
* Provide a descriptive error ``code`` to the constructor, to allow
121+
programmatic use (e.g. in tests) that will not vary with translations::
121122

122123
# Good
123124
ValidationError(_("Invalid value"), code="invalid")

0 commit comments

Comments
 (0)