Skip to main content

Validata

Dataclass and validation made simple as well as powerful.

Installation

You can install Validata using pip:

pip install validata

To install from GitHub:

git clone https://github.com/MirS0bhan/validata && cd validata
pip install .

Usage

Basic Example

Here’s how to define a dataclass and use the validation features:

from vlidt import BaseModel

class A(BaseModel):
    x: int
    y: int

class B(A):
    z: list[str]

c = B(5, 6, ["abc", "xyz"])

Validation

You can validate the fields of your dataclass instances easily:

from vlidt import validate

# Validate the instance
is_valid = validate(c)
print(is_valid)  # Returns True if valid, otherwise False

Dumping and Loading Data

You can convert your dataclass instances to and from dictionaries:

# Dumping the instance to a dictionary
data_dict = dump(c)
print(data_dict)  # Output: {'x': 5, 'y': 6, 'z': ['abc', 'xyz']}

# Loading from a dictionary
new_instance = load(B, data_dict)
print(new_instance)  # Output: B(x=5, y=6, z=['abc', 'xyz'])

Nested Dataclasses

Validata supports nested dataclasses, allowing you to create more complex data structures:

class C(BaseModel):
    a: A
    additional_info: str

instance_c = C(a=c, additional_info="Some info")
print(instance_c)

Features

  • Automatic Validation: Validate dataclass fields with minimal effort.
  • Dump and Load: Easily convert dataclass instances to and from dictionaries.
  • Nested Support: Handle nested dataclass instances seamlessly.
  • Type Annotations: Leverage Python’s type hints for better code clarity and error checking.

Contributing

Contributions are welcome! If you would like to contribute to Validata, please follow these steps:

  • Fork the repository.
  • Create a new branch for your feature or bugfix.
  • Make your changes and commit them.
  • Push to your branch and submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for more details. Contact

For any inquiries or suggestions, feel free to reach out via GitHub Issues.

Release files for vlidt 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vlidt 0.2.2
File Size Uploaded
vlidt-0.2.2.tar.gz 3.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vlidt 0.2.2
File Interpreter ABI Platform
vlidt-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 7.5 kB

Release files / vlidt-0.2.2.tar.gz

Download URL vlidt-0.2.2.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9268d45d97b894b61ff8d6682c09a5710ce193b064f1dbc5c000eafb166c5d7f
BLAKE2b-256 checksum
How to use checksums
2369f4d66c78698e7053df4e1b6d28c8cf7ed9c994267777b1f8f1e4cf9707cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Linux/6.9.8-arch1-1

Release files / vlidt-0.2.2-py3-none-any.whl

Download URL vlidt-0.2.2-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
38be3328510ffb0a56c49e9b5eb26554f9549e3ad5b8b995b6335db6f9aca49f
BLAKE2b-256 checksum
How to use checksums
09dafcf0913af186d165f960ee9e8f6815f01c8712f785c09b9887fe01220b95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Linux/6.9.8-arch1-1

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page