Skip to content

Commit f72183c

Browse files
committed
validator example added
1 parent aa28507 commit f72183c

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎validators/utils.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,26 @@ def validator(func, *args, **kwargs):
5959
function is called and returns False value this decorator returns
6060
ValidationFailure object.
6161
62+
Example:
63+
64+
::
65+
66+
67+
>>> from validators import validator
68+
69+
70+
>>> @validator
71+
>>> def even(value):
72+
... return not (value % 2)
73+
74+
75+
>>> even(4)
76+
True
77+
78+
>>> even(5)
79+
ValidationFailure(func=even, args={'value': 5})
80+
81+
6282
:param func: function to decorate
6383
:param *args: positional function arguments
6484
:param **kwargs: key value function arguments

0 commit comments

Comments
 (0)