Skip to main content

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


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.2.tar.gz (4.5 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.2-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: XenValidator-0.1.2.tar.gz
  • Upload date:
  • Size: 4.5 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.2.tar.gz
Algorithm Hash digest
SHA256 dee178f1c86284644e2c3bd86542ab4cd31577d7f9135fc4e149f508732e0cf0
MD5 ca0b87ca1b2753077c90fd27b6868547
BLAKE2b-256 c1ee25e341e647500134391bcd111348189a50c10f328b334a9cba832f1bdefb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: XenValidator-0.1.2-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

Hashes for XenValidator-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2a1ee3ebcc8ff855c913e00e7e12878c79887f6fb96584985c87e4fadc612223
MD5 64715890995016d37d71608456f7b53a
BLAKE2b-256 569446a580e42c08c7c3f57d3b4a464196f8fa87374680005f01b9a4a2a2bb47

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