Python type validation decorator, validates input and output types
pip install type-valid
from type_valid import type_valid
@type_valid
def hello(name: str) -> str:
return name
#valid
hello("Bob")
@type_valid
def hello_second(name: str) -> int:
return name
#invalid output
hello_second("edds")
@type_valid
def user(name: str, age: int, salary: float) -> str:
return name+str(age)+str(salary)
#valid
user(name="Bob", age=25, salary=1000.00)
TypeError: in method 'hello', Argument 'name' is not of type <class 'str'>, received <class 'int'>
TypeError: in method 'user', Argument 'name' is required
TypeError: in method 'hello_second', output 'edds' is not of type <class 'int'>, received <class 'str'>
- Validate input DONE
- Validate Output DONE
- Validate input **kwargs ?
- Validate mandatory **kwargs ?
- Multiple types ?
str ""
int 4
float 10.5
list []
tuple ()
...