Skip to main content

XenValidator is schema validation library for Python, You can Validate Strings, Numbers, Objects, Arrays, Dates, URLs, Ip addresses & 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


Download files

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

Source Distribution

XenValidator-0.1.4.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

XenValidator-0.1.4-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file XenValidator-0.1.4.tar.gz.

File metadata

  • Download URL: XenValidator-0.1.4.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for XenValidator-0.1.4.tar.gz
Algorithm Hash digest
SHA256 dcbfa21f5b61dd2b6fa00023c4f1fe711b0986e96da630d130c404fd2531b851
MD5 4fdde7b35c1396fe138860d5e66815ed
BLAKE2b-256 62c1d5f9f157512cf9ac25cba3aa513818a59e20e88a123abb67d84baf31330e

See more details on using hashes here.

File details

Details for the file XenValidator-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: XenValidator-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for XenValidator-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d8ca41f4c4c7055efda3566ae612682eab45095bf793c93fd91281e97ce0051f
MD5 5fb7de455bba829620444c7b7353a051
BLAKE2b-256 1da86833de188a42571190c6f2c277e6bf456bdd21a69cf8a2c2e4c690eaa8b2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page