Metadata-Version: 2.1
Name: configmate-pydantic-validator
Version: 0.0.1
Summary: Extends configmate with pydantic validation logic.
Author: Arthur Böök
Requires-Python: >=3.8,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: configmate (>=0.1.3,<0.2.0)
Requires-Dist: pydantic (>=1.0,<3.0)
Description-Content-Type: text/markdown

# configmate-pydantic-validator
Extends `configmate` to levarage Pydantic for config validation.

## Installation
```bash
pip install configmate-pydanticvalidator
```
OR directly with the extras of `configmate`:
```bash
pip install configmate[pydantic]
```

## Usage
By loading this plugin, `configmate` will use Pydantic to validate the config. 
Under the hood, a new validator is registered to `configmate.components.validators.TypeValidatorFactory`.
This validator will be used for any non-function passed to `validation` in configmate.get_config.

```python
from typing import Dict
import dataclasses

import configmate

@dataclasses.dataclass
class Config:
    host: str
    port: int

config = configmate.get_config(
    "config.json",  # main config
    validation=Dict[str, str], # pydantic will handle validation
)
## >> {'host': 'localhost', 'port': '8080'} # note that port is a string due to pydantic

config = configmate.get_config(
    "config.json",  # main config
    validation=Config, # pydantic will handle validation
) 
## >> Config(host='localhost', port=8080) # port is an int as expected

config = configmate.get_config(
    "config.json",  # main config
    validation=lambda config_dict: ..., # callables will be called with the config dict (as without this plugin)
)
## >> ... # whatever the callable returns
```
