Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python

#pip install danielutils
from danielutils import validate

@validate(str)
def f1(name):
    pass

@validate([int, float])
def f2(number):
    pass

@validate([str, lambda s: len(s) < 10, "short_string must be shorter than 10 letters"])
def f3(short_string):
    pass

#will raise error because duplicate function name in same context
@validate([[int, float], lambda age: age > 0, "age must be bigger then 0"])
def f3(age):
    pass

@validate(None, int, int, None)
def f5(skip, dont_skip, dont_skip2, skip2):
    pass
Source by www.python.org #
 
PREVIOUS NEXT
Tagged: #python
ADD COMMENT
Topic
Name
4+4 =