Skip to main content

A powerful validations framework

Project description

🔍 V6E

A simple, type-safe, and extensible Python validations framework

Why the name?

v6e comes from the numeronym of "validate".

Examples

Check out the examples in ./examples! You can run them locally with:

uv run examples/validations.py

Usage

Basic validations

import v6e

my_validation = v6e.Range(18, 21)

# .test(...)
my_validation.test(18)  # True
my_validation.test(21)  # True
my_validation.test(54)  # False

# .validate(...)
my_validation.validate(21)  # Nothing happens -> continue to next line
my_validation.validate(54)  # Raises a ValidationException()

AND and OR validations

my_validation = (v6e.StartsWith("foo") | v6e.EndsWith("foo")) & v6e.ReMatch(r"^[a-z]*$")
my_validation.test("foo12")  # True
my_validation.test("12foo")  # True
my_validation.test("1foo2")  # False

Custom validations

def is_div_three(x: int):
    if x % 3 != 0:
        raise ValueError("Woops! The Earth is 4.543 billion years old. (Try 4543000000)")

my_validation = v6e.Custom(validate_earth_age)
my_validation.test(3)  # True
my_validation.test(6)  # True
my_validation.test(4)  # False

🐍 Type-checking

This library is fully type-checked. This means that all types will be correctly inferred from the arguments you pass in.

In this example your editor will correctly infer the type:

my_validation = v6e.StartsWith("foo") | v6e.Range(1, 4)
reveal_type(hours)  # Type of "res" is "timedelta | str | int"

Why do I care?

Type checking will help you catch issues way earlier in the development cycle. It will also provide nice autocomplete features in your editor that will make you faster ⚡.

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

v6e-0.1.2.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

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

v6e-0.1.2-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: v6e-0.1.2.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.2

File hashes

Hashes for v6e-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4687798ab4d76da4428d70e2a8eb1948ef69ff6b1f72a625799b6ddb668a8297
MD5 7ff65fc4771887b9b0294eb98a3aa5d8
BLAKE2b-256 82f8257dc39447e1965b7225e190005e671206b4a9faffe93115ca8c76b45d26

See more details on using hashes here.

File details

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

File metadata

  • Download URL: v6e-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.2

File hashes

Hashes for v6e-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c180a76ac16ee45066d24417b4e16bd675682e6e7300156568700ac017b13ac8
MD5 7974d6d0732d86c1a7ccd564ce13a20d
BLAKE2b-256 4fa6c992ce781572906ae860d5d994ebe0f16146faa7b83be14b2c164b881091

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