Skip to main content

The dataclass_plus is a fastest type validation library for the dataclass

Project description

dataclass_plus

The dataclass_plus is a fastest type validation library for the dataclass

Example

from dataclass_plus import dataclass_plus
from typing import List, Dict, Tuple


@dataclass_plus
class Model:
    id: int
    name: str
    dict_example: Dict[str, str]
    list_example: List[int] # this field is required
    tuple_example: Tuple[str, float] = None # this field is not required because set default None


Model(
    id=1, 
    name='Test Test', 
    dict_example={"test": "test"}, 
    list_example=[1,2],
    tuple_example=("test", 1.2)
)
# => Model(id=1, name='Test Test', dict_example={"test": "test"}, list_example=[1,2], tuple_example=("test", 1.2))
# Invalid Model
Model(
    id=1, 
    name='Test Test', 
    dict_example={"test": 1}, 
    list_example=[1,2],
    tuple_example=("test", 1.2)
)
# => ValueError: {'test': 1} is not typing.Dict[str, str]

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for dataclass-plus, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size dataclass_plus-0.0.1-py3.8.egg (5.1 kB) File type Egg Python version 3.8 Upload date Hashes View hashes
Filename, size dataclass_plus-0.0.1-py3-none-any.whl (3.1 kB) File type Wheel Python version py3 Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page