You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/init.rst
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -147,6 +147,8 @@ The method has to accept three arguments:
147
147
#. the *attribute* that it's validating, and finally
148
148
#. the *value* that is passed for it.
149
149
150
+
These values are passed as *positional arguments*, therefore their names don't matter.
151
+
150
152
If the value does not pass the validator's standards, it just raises an appropriate exception.
151
153
152
154
>>> @define
@@ -172,6 +174,7 @@ Callables
172
174
If you want to re-use your validators, you should have a look at the ``validator`` argument to `attrs.field`.
173
175
174
176
It takes either a callable or a list of callables (usually functions) and treats them as validators that receive the same arguments as with the decorator approach.
177
+
Also as with the decorator approach, they are passed as *positional arguments* so you can name them however you want.
175
178
176
179
Since the validators run *after* the instance is initialized, you can refer to other attributes while validating:
0 commit comments