configmate-pydantic-validator


Nameconfigmate-pydantic-validator JSON
Version 0.1.0 PyPI version JSON
download
home_page
SummaryExtends configmate with pydantic validation logic.
upload_time2024-02-17 00:18:40
maintainer
docs_urlNone
authorArthur Böök
requires_python>=3.8,<4.0
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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
```
            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "configmate-pydantic-validator",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Arthur B\u00f6\u00f6k",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/3c/34/be8df016dddf73c0c62429981c8c57719978aa2a303b83130cf562eedaa5/configmate_pydantic_validator-0.1.0.tar.gz",
    "platform": null,
    "description": "# configmate-pydantic-validator\nExtends `configmate` to levarage Pydantic for config validation.\n\n## Installation\n```bash\npip install configmate-pydanticvalidator\n```\nOR directly with the extras of `configmate`:\n```bash\npip install configmate[pydantic]\n```\n\n## Usage\nBy loading this plugin, `configmate` will use Pydantic to validate the config. \nUnder the hood, a new validator is registered to `configmate.components.validators.TypeValidatorFactory`.\nThis validator will be used for any non-function passed to `validation` in configmate.get_config.\n\n```python\nfrom typing import Dict\nimport dataclasses\n\nimport configmate\n\n@dataclasses.dataclass\nclass Config:\n    host: str\n    port: int\n\nconfig = configmate.get_config(\n    \"config.json\",  # main config\n    validation=Dict[str, str], # pydantic will handle validation\n)\n## >> {'host': 'localhost', 'port': '8080'} # note that port is a string due to pydantic\n\nconfig = configmate.get_config(\n    \"config.json\",  # main config\n    validation=Config, # pydantic will handle validation\n) \n## >> Config(host='localhost', port=8080) # port is an int as expected\n\nconfig = configmate.get_config(\n    \"config.json\",  # main config\n    validation=lambda config_dict: ..., # callables will be called with the config dict (as without this plugin)\n)\n## >> ... # whatever the callable returns\n```",
    "bugtrack_url": null,
    "license": "",
    "summary": "Extends configmate with pydantic validation logic.",
    "version": "0.1.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "76ed2dbb95804795eccfb13906283054b66010cb285fc69a37e80f603996a62f",
                "md5": "93c17aa02c3b79f59b8b0677bd263397",
                "sha256": "4d64b23ccec404183511451b2795105ec410626b8029707b9ab0331c3e6f46e9"
            },
            "downloads": -1,
            "filename": "configmate_pydantic_validator-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "93c17aa02c3b79f59b8b0677bd263397",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 2669,
            "upload_time": "2024-02-17T00:18:39",
            "upload_time_iso_8601": "2024-02-17T00:18:39.527867Z",
            "url": "https://files.pythonhosted.org/packages/76/ed/2dbb95804795eccfb13906283054b66010cb285fc69a37e80f603996a62f/configmate_pydantic_validator-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3c34be8df016dddf73c0c62429981c8c57719978aa2a303b83130cf562eedaa5",
                "md5": "e1351a38c88a904b9b65c92b4ab85d95",
                "sha256": "c37b8d0a4216f354e11c058a8e0f4538e476270a9a43f0a77642fb07be30b821"
            },
            "downloads": -1,
            "filename": "configmate_pydantic_validator-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e1351a38c88a904b9b65c92b4ab85d95",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 1891,
            "upload_time": "2024-02-17T00:18:40",
            "upload_time_iso_8601": "2024-02-17T00:18:40.975649Z",
            "url": "https://files.pythonhosted.org/packages/3c/34/be8df016dddf73c0c62429981c8c57719978aa2a303b83130cf562eedaa5/configmate_pydantic_validator-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-17 00:18:40",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "configmate-pydantic-validator"
}
        
Elapsed time: 0.29452s