XenValidator is schema validation library for Python, You can Validate Strings, Numbers, Objects, Arrays, Dates, URLs & more. You can even create your custom validators! Make sure to give it a ⭐ on github.
Project description
XenValidator
XenValidator is a powerful, flexible, and easy-to-use Python library for validating data structures. It simplifies the process of defining complex validation rules, handling cross-field dependencies, and providing informative error messages.
Features
Comprehensive Validation: Supports validation for strings, numbers, dates, arrays, urls, and custom data types.
Custom Error Handling: Easily customize error messages for various validation rules.
Flexible Date Formats: Supports multiple date formats to match various use cases.
Installation
Install XenValidator using pip:
pip install xenvalidator
Example usage:
Import the package into to your app:
from XenValidator import X, Object, ValidationError
Create and validate the schema.
Schema = Object({
"Name": X["STRING"](),
"Age": X["NUMBER"]().min(2),
"Tags": X["ARRAY"](),
})
try:
Data = {
"Name": "John Doe",
"Age": 18,
"Tags": ["TAG1", "TAG2", "TAG3"],
}
Schema.validate(Data)
print("Data is valid:", Data)
except ValidationError as e:
print("Data is invalid:", e)
Explanation
- Name: Required field validated as a string. A custom error message is provided if validation fails.
- Age: Number field with a minimum value of 2. A custom error message is triggered if validation fails.
- Tags: Array field validated to ensure it is indeed an array. A custom error message is returned if validation fails.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file XenValidator-0.1.3-py3-none-any.whl.
File metadata
- Download URL: XenValidator-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67d1c1b4349138077aaf03bdfc1c7d8aea5eaa63eb7b8a3afe59b7f41ee0bf4e
|
|
| MD5 |
6ce6b3e6cf268cde90a5b154e7a0907e
|
|
| BLAKE2b-256 |
c0ef3842b13bfbe3c690e5cbceda97d133251bbce52828ac78873b777499fc75
|