Skip to main content

An argument validation library.

Project description

The Arbiter

The arbiter is a library for writing validations using a simple syntax. What kind of validations? Originally it was intended to validate named arguments. But use your imagination. It is really, really flexible.

The syntax has simple rules:

  • Validators must be a list, or a dictionary.
  • Lists are treated as "AND" conditions.
  • Dictionaries are used for "OR" and "XOR" conditions. Requirements:
    • Keys must be strings and start with "OR" or "XOR" (case insensitive). Beyond that, you can use any suffix you like for clarity.
    • Values must be a list.
  • Values must be strings

You can nest things all you want. For example:

contact_validator = Arbiter([
    'name', 'address',                                   # must have name and address
    {'or_contact': ['phone', 'email']},                  # also need phone or email, or both
    {'xor_location': ['street_address', 'coordinates']}  # and, street_address or coordinates, but not both
])

Using dictionaries and lists you can create simple or complex validation rules.

Why "The Arbiter?" Because an arbiter is considered the ultimate authority when it comes to settling a dispute. I thought it was more fun than "argument validator."

Current Limitations

This does not do any type validation on arguments. It only verifies whether or not it exists.

Code Examples

Verifying a simple named argument.

from thearbiter.validator import Arbiter

required_favorites = Arbiter(['animal'])

def hi_there(name, **favorites):
    # this will raise an AttributeException if the "animal" keyword is not found. 
    required_favorites.validate_args(**favorites)

More examples to come.

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

The-Arbiter-1.0.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

The_Arbiter-1.0.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file The-Arbiter-1.0.0.tar.gz.

File metadata

  • Download URL: The-Arbiter-1.0.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

File hashes

Hashes for The-Arbiter-1.0.0.tar.gz
Algorithm Hash digest
SHA256 36dd2e5cc519008279928d3abb92fc3b053f5770f050d1736e90b5659f9e72a7
MD5 a7b0e9cf416055f52f96871464722ef8
BLAKE2b-256 7b9e159148fee4ab5ddd4f4d5bcb7414f50f6fb272730f38ed41e7ee7cdd6559

See more details on using hashes here.

File details

Details for the file The_Arbiter-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: The_Arbiter-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

File hashes

Hashes for The_Arbiter-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f421505551c3675c09fd67a3a02b7ad5da363a9db33a46245900a7bd1124a84a
MD5 2b222f206ae87d29a828cacd239fdc2e
BLAKE2b-256 f9b5f3193062a9f4d81ac851e27457765f38bbd1ce49a02f6984d71a00698187

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