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.
Metadata
Release files for argsv 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| argsv-0.1.0.tar.gz | 30.8 kB | Without provenance | Details for argsv-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| argsv-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for argsv-0.1.0-py3-none-any.whl |
Total release size: 62.0 kB
Release files / argsv-0.1.0.tar.gz
| Download URL | argsv-0.1.0.tar.gz |
|---|---|
| Size | 30.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4f0bfb1984ccf2fc4a9d96de67d18a2c5710a4d7bd783201486d87127f6fa9c8
|
|
BLAKE2b-256 checksum How to use checksums |
b8644283933d0c676a6af0c337d1689d61cfd02cedc5552aa151b3194b26fcad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.2
|
Release files / argsv-0.1.0-py3-none-any.whl
| Download URL | argsv-0.1.0-py3-none-any.whl |
|---|---|
| Size | 31.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f2f12aad5432dc12870b19ea6e7ecd11ee62e25253b39dc1c65bc23694b928e5
|
|
BLAKE2b-256 checksum How to use checksums |
cf003905a89ccea3670feb408482b4fff6514712f14d01a71ca55dd1bb0a2cde
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.2
|
Security for argsv 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.