Python Type validator with decorators
Project description
# python-type-valid
[](https://travis-ci.org/edmhs/python-type-valid)
[](https://codecov.io/gh/edmhs/python-type-valid)
[](https://codeclimate.com/github/edmhs/python-type-valid)
Python type validation decorator, validates input and output types
### Installation
~~~sh
pip install type-valid
~~~
### Usage
~~~python
from type_valid import type_valid
@type_valid
def hello(name: str) -> str:
return name
#valid
hello("Bob")
#invalid
hello(1)
@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)
~~~
### Raises TypeError
~~~sh
TypeError: in method 'hello', Argument 'name' is not of type <class 'str'>, received <class 'int'>
~~~
### Todo:
* Validate input DONE
* Validate Output DONE
* Validate input **kwargs ?
* Validate mandatory **kwargs ?
* Multiple types ?
### Types examples
~~~
str ""
int 4
float 10.5
list []
tuple ()
...
~~~
[](https://travis-ci.org/edmhs/python-type-valid)
[](https://codecov.io/gh/edmhs/python-type-valid)
[](https://codeclimate.com/github/edmhs/python-type-valid)
Python type validation decorator, validates input and output types
### Installation
~~~sh
pip install type-valid
~~~
### Usage
~~~python
from type_valid import type_valid
@type_valid
def hello(name: str) -> str:
return name
#valid
hello("Bob")
#invalid
hello(1)
@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)
~~~
### Raises TypeError
~~~sh
TypeError: in method 'hello', Argument 'name' is not of type <class 'str'>, received <class 'int'>
~~~
### Todo:
* Validate input DONE
* Validate Output DONE
* Validate input **kwargs ?
* Validate mandatory **kwargs ?
* Multiple types ?
### Types examples
~~~
str ""
int 4
float 10.5
list []
tuple ()
...
~~~
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Built Distribution
Close
Hashes for type_valid-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a111bf8d8833c0e01e26c6673696bdd98eea12f1abf8c729110ceae44d3b0482 |
|
MD5 | 13f36cb2fc6f807062b00788b8707f71 |
|
BLAKE2-256 | 017dfcd27d3fa0667949031ef3f61a9e9562d7aca03d3264103de9c91bb302e4 |