Skip to content

Commit aa28507

Browse files
committed
Docs for validator decorator
1 parent bd29a3a commit aa28507

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

‎docs/index.rst‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,12 @@ uuid
111111
----
112112
.. autofunction:: uuid
113113

114+
115+
116+
Internals
117+
=========
118+
119+
validator
120+
---------
121+
122+
.. autofunction:: validator

‎validators/utils.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ def __nonzero__(self):
3535

3636

3737
def func_args_as_dict(func, args, kwargs):
38+
"""
39+
Returns given function positional and key value arguments as an ordered
40+
dictionary.
41+
"""
3842
arg_names = list(
3943
OrderedDict.fromkeys(
4044
itertools.chain(
@@ -50,6 +54,15 @@ def func_args_as_dict(func, args, kwargs):
5054

5155

5256
def validator(func, *args, **kwargs):
57+
"""
58+
A decorator that makes given function validator. Whenever the given
59+
function is called and returns False value this decorator returns
60+
ValidationFailure object.
61+
62+
:param func: function to decorate
63+
:param *args: positional function arguments
64+
:param **kwargs: key value function arguments
65+
"""
5366
def wrapper(func, *args, **kwargs):
5467
value = func(*args, **kwargs)
5568
if not value:

0 commit comments

Comments
 (0)