Metadata-Version: 2.4
Name: func-validator
Version: 0.13.0
Summary: MATLAB-style function argument validation for Python - clean, simple, and reliable.
Author-email: Patrick Boateng <patrickboateng@patrickboateng.tech>
License: MIT License
        
        Copyright (c) 2025 func-validator
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: homepage, https://github.com/patrickboateng/func-validator
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: validators==0.35.0
Dynamic: license-file

# func-validator

[![Github](https://img.shields.io/badge/func--validator-000000?style=flat&logo=github&logoColor=white)](https://github.com/patrickboateng/func-validator)
[![PyPI Latest Release](https://img.shields.io/pypi/v/func-validator?style=flat&logo=pypi)](https://pypi.org/project/func-validator/)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/func-validator.svg?logo=python&style=flat)](https://pypi.python.org/pypi/func-validator/)
[![Unit-Tests](https://github.com/patrickboateng/func-validator/actions/workflows/func-validator-unit-tests.yml/badge.svg)](https://github.com/patrickboateng/func-validator/actions/workflows/func-validator-unit-tests.yml)
[![Coverage Status](https://coveralls.io/repos/github/patrickboateng/func-validator/badge.svg?branch=main)](https://coveralls.io/github/patrickboateng/func-validator?branch=main)
[![license](https://img.shields.io/pypi/l/func-validator?style=flat&logo=opensourceinitiative)](https://opensource.org/license/mit/)

MATLAB-style function argument validation for Python - clean, simple, and
reliable.

## Table of Contents

- [Installation](#installation)
- [Imports](#imports)
- [Usage](#usage)
- [Validators](#validators)
- [License](#license)

## Installation

```shell
pip install func-validator
```

## Imports

- Import for the function decorator

  ```python
  from func_validator import validate_func_args
  from func_validator import validate_func_args_at_runtime 
  ```

- Import for the validators

  ```python
  from func_validator import MustBeGreaterThan, MustMatchRegex 
  from func_validator.validators.numeric_arg_validators import MustBeGreaterThan
  ```

  There are 3 other modules you can import validators from, namely:

    - [collection_arg_validators](#collection-validators)
    - [datatype_arg_validators](#datatype-validators)
    - [text_arg_validators](#text-validators)

> [!NOTE]
> All validator objects (functions/callables) can be imported from the
> `func_validator` namespace

## Usage

```python

>> > from typing import Annotated

>> > from func_validator import validate_func_args
>> > from func_validator.validators.numeric_arg_validators import (
    MustBePositive,

...
MustBeNegative)

>> >

@validate_func_args


...


def func(a: Annotated[int, MustBePositive],
         ...b: Annotated[float, MustBeNegative]

):
...
return (a, b)

>> > func(10, -10)  # ✅ Correct
(10, -10)

>> > func(-10, -10)  # ❌ Wrong -10 is not positive and 10 is not negative
Traceback(most
recent
call
last):
...
ValidationError: a:-10
must
be > 0.0.

>> > func(0, -10)  # ❌ Wrong 0 is not positive
Traceback(most
recent
call
last):
...
ValidationError: a:0
must
be > 0.0.

>> > func(20, 10)  # ❌ Wrong 10 is not negative
Traceback(most
recent
call
last):
...
ValidationError: b:10
must
be < 0.0.

```

## Validators

This is not the exhaustive list for all validators, checkout
the [docs](https://func-validator.readthedocs.io/en/latest/)
for more examples.

### Collection Validators

<table>
    <tr>
        <td>MustBeMemberOf</td>
        <td>Validate that argument value is in a collection</td>
    </tr>
    <tr>
        <td>MustBeEmpty</td>
        <td>Validate that argument value is empty</td>
    </tr>
</table>

### DataType Validators

<table>
    <tr>
        <td>MustBeA</td>
        <td>Validates that the value is of the specified type</td>
    </tr>
</table>

### Numeric Validators

<table>
    <tr>
        <td>MustBePositive</td>
        <td>Validate that argument value is positive</td>
    </tr>
    <tr>
        <td>MustBeNegative</td>
        <td>Validate that argument value is negative</td>
    </tr>
</table>

### Text Validators

<table>
    <tr>
        <td>MustMatchRegex</td>
        <td>Validates that the value matches the provided regular expression.</td>
    </tr>
</table>

## License

MIT License
