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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

XenValidator-0.1.3-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

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

Hashes for XenValidator-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 67d1c1b4349138077aaf03bdfc1c7d8aea5eaa63eb7b8a3afe59b7f41ee0bf4e
MD5 6ce6b3e6cf268cde90a5b154e7a0907e
BLAKE2b-256 c0ef3842b13bfbe3c690e5cbceda97d133251bbce52828ac78873b777499fc75

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