Skip to main content

argsv is a library for validating arguments passed to callables. With this library, you can validate arguments sent to callables in a simpler, more readable, and well-defined context.

Project description

pypi support-version license commit

Getting started

argsv is a library for validating arguments passed to callables. With this library, you can validate arguments sent to callables in a simpler, more readable, and well-defined context.

from argsv import argsval

@argsval(b=lambda x: x != 0)
def div(a, b):
    return a / b

Here, with the help of the argsval decorator, the operation of the div function will only proceed if the argument passed to parameter b satisfies the specified lambda condition (i.e., it is not equal to zero). Otherwise, the validation process fails, and the corresponding error is raised.

For those who prefer to perform argument validation within the body of a function, this option is also available:

from argsv import ArgsVal

def div(a, b):
    ArgsVal(
      div, {'b': lambda x: x != 0}, a, b
    ).validate()
    # Function code:
    return a / b

There are built-in, pre-implemented validators for common and frequently used validations, which you can easily utilize:

from argsv import argsval
from argsv.validators import multival, typeval, fromto

@argsval(a=multival(typeval(int), fromto(0, 9)))
def dummy(a):
    return a

In this example, using the multival validator—which allows multiple validation operations for a single argument—the type of argument a is validated by the typeval validator, while the valid range for parameter b is enforced by the fromto validator.

📖 For more information, I recommend checking out the argsv documentation.

Installation

You can use pip to install:

python3 -m pip install argsv

And also to upgrade:

python3 -m pip install --upgrade argsv

Features

  • Lightweight: It doesn't rely on any external modules or libraries.
  • Readable: It separates the validation process from the main code, improving clarity.
  • Simplifies Validation: Makes the argument validation process easier.
  • Precise Error Reporting: Accurately displays errors in the validation process.
  • Universal Compatibility: Works with all types of callables.
  • Custom Validators: Allows you to implement your own customized validators.
  • Built-in Validators: Provides common and useful built-in validators.
  • Extensible: Designed to be flexible and expandable.

Bugs/Requests

Please send bug reports and feature requests through Github issue tracker.

License

argsv is a free and open source project under the GPL-v3 LICENSE. Any contribution is welcome. You can do this by registering a pull request.

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

argsv-0.1.0.tar.gz (30.8 kB view details)

Uploaded Source

Built Distribution

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

argsv-0.1.0-py3-none-any.whl (31.2 kB view details)

Uploaded Python 3

File details

Details for the file argsv-0.1.0.tar.gz.

File metadata

  • Download URL: argsv-0.1.0.tar.gz
  • Upload date:
  • Size: 30.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for argsv-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4f0bfb1984ccf2fc4a9d96de67d18a2c5710a4d7bd783201486d87127f6fa9c8
MD5 67d348bbd7423552aa5e24fee3c6a5f2
BLAKE2b-256 b8644283933d0c676a6af0c337d1689d61cfd02cedc5552aa151b3194b26fcad

See more details on using hashes here.

File details

Details for the file argsv-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: argsv-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 31.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for argsv-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f2f12aad5432dc12870b19ea6e7ecd11ee62e25253b39dc1c65bc23694b928e5
MD5 edf555021adec0930c71b958bd382d3a
BLAKE2b-256 cf003905a89ccea3670feb408482b4fff6514712f14d01a71ca55dd1bb0a2cde

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