MATLAB-style function argument validation for Python - clean, simple, and reliable.
Project description
func-validator
MATLAB-style function argument validation for Python.
Installation
$ pip install func-validator
Usage
from typing import Annotated
from func_validator import (validate_func_args_at_runtime,
MustBePositive,
MustBeNegative)
@validate_func_args_at_runtime
def func(a: Annotated[int, MustBePositive],
b: Annotated[float, MustBeNegative]):
pass
func(10, -10) # ✅ Correct
func(-10, 10) # ❌ Wrong -10 is not positive and 10 is not negative
func(0, -10) # ❌ Wrong 0 is not positive
Validators
Numeric Value Validation
| MustBePositive | Validate that argument value is positive |
| MustBeNonPositive | Validate that argument value is non-positive |
| MustBeNegative | Validate that argument value is negative |
| MustBeNonNegative | Validate that argument value is non-negative |
Comparison Validation
| MustBeEqual | Validate that argument value is equal to another value |
| MustBeNotEqual | Validate that argument value is not equal to another value |
| MustBeGreaterThan | Validate that argument value is greater than another value |
| MustBeGreaterThanOrEqual | Validate that argument value is greater than or equal to another value |
| MustBeLessThan | Validate that argument value is less than another value |
| MustBeLessThanOrEqual | Validate that argument value is less than or equal to another value |
Membership Validation
| MustBeIn | Validate that argument value is in a collection |
| MustBeBetween | Validate that argument value is between two other values |
Collection/Iterable Validation
| MustBeEmpty | Validate that a collection is empty |
| MustBeNonEmpty | Validate that a collection is non-empty |
| MustHaveLengthEqual | Validate that a collection has a specific length |
| MustHaveLengthGreaterThan | Validate that a collection has length greater than a specific value |
| MustHaveValuesBetween | Validate that all values in a collection are between two other values |
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file func_validator-0.9.0.tar.gz.
File metadata
- Download URL: func_validator-0.9.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f8925941d750061fc358b4dbfd5c3c532cec9ae5c7acdca7a2a2f2182d54715
|
|
| MD5 |
6deffb8f65f53381bfb08e5ef4c17eab
|
|
| BLAKE2b-256 |
dcdffbcb29810f22a00c424fd86148c3b04f9242e86c7df71dd238a2dcfda90f
|
Provenance
The following attestation bundles were made for func_validator-0.9.0.tar.gz:
Publisher:
func-validator-publish.yml on patrickboateng/func-validator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
func_validator-0.9.0.tar.gz -
Subject digest:
1f8925941d750061fc358b4dbfd5c3c532cec9ae5c7acdca7a2a2f2182d54715 - Sigstore transparency entry: 397118288
- Sigstore integration time:
-
Permalink:
patrickboateng/func-validator@bb58c9b956bf8278c5702a12c34868e768f86751 -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/patrickboateng
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
func-validator-publish.yml@bb58c9b956bf8278c5702a12c34868e768f86751 -
Trigger Event:
push
-
Statement type:
File details
Details for the file func_validator-0.9.0-py3-none-any.whl.
File metadata
- Download URL: func_validator-0.9.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b7705deea2b0caaa88311f50622ae27c17a53c28073680e2d341f90e3231c23
|
|
| MD5 |
385274d5634dad2c98ea12f409e89337
|
|
| BLAKE2b-256 |
3cea4f95757f6b981b17eae0ac2dd6cde0965f0497218e4360290ee13a39ee32
|
Provenance
The following attestation bundles were made for func_validator-0.9.0-py3-none-any.whl:
Publisher:
func-validator-publish.yml on patrickboateng/func-validator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
func_validator-0.9.0-py3-none-any.whl -
Subject digest:
2b7705deea2b0caaa88311f50622ae27c17a53c28073680e2d341f90e3231c23 - Sigstore transparency entry: 397118307
- Sigstore integration time:
-
Permalink:
patrickboateng/func-validator@bb58c9b956bf8278c5702a12c34868e768f86751 -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/patrickboateng
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
func-validator-publish.yml@bb58c9b956bf8278c5702a12c34868e768f86751 -
Trigger Event:
push
-
Statement type: