![Stars][stars-shield]
[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]
[![Code Coverage][coverage-shield]](#code-coverage)
<br />
<div align="center">
<a href="https://github.com/hendrikboeck/parasite">
<img src="https://raw.githubusercontent.com/hendrikboeck/parasite/main/.github/parasite_logo.png" alt="Logo" width="128" height="128">
</a>
<h1 align="center">parasite <code>v0.1.10</code></h1>
<p align="center">
<code>zod</code> inspired library for Python 3.11+
<br />
<a href="https://github.com/hendrikboeck/parasite/issues/new?labels=bug&template=bug-report---.md">Report Bug</a>
|
<a href="https://github.com/ohendrikboeck/parasite/issues/new?labels=enhancement&template=feature-request---.md">Request Feature</a>
</p>
</div>
> [!WARNING]
>
> This library is under active development, expect things to break or not to work as expected.
> Creating an issue for bugs you encounter would be appreciated. Documentation is currently work in
> progress.
## Table of Contents
- [Why?](#why)
- [What about the name?](#what-about-the-name)
- [Getting Started](#getting-started)
- [Installing](#installing)
- [Example usage](#example-usage)
- [Documentation](#documentation)
- [Code Coverage](#code-coverage)
- [License (_MIT License_)](#license-mit-license)
## Why?
Data and object validation in Python is essential to ensure that the inputs to a program are
accurate and adhere to expected formats, thereby preventing runtime errors and enhancing code
reliability. The TypeScript library `zod` offers a concise and expressive syntax for schema
validation, making it easier to define and enforce data structures. Implementing a similar library
in Python would greatly benefit developers by providing a streamlined, declarative approach to
validation, reducing boilerplate code and improving maintainability. This would facilitate more
robust data handling and enhance the overall quality of Python applications.
## What about the name?
I chose the name "Parasite" for this library because it draws heavy inspiration from the TypeScript
`zod` library, which excels in schema validation with its concise and expressive syntax. The name
"Parasite" is also a nod to one of Superman's iconic supervillains, serving as an homage to the
library that inspired this creation.
## Getting Started
### Installing
Install using `pip`:
```sh
pip install parasite
```
Install using `poetry` CLI:
```sh
poetry add parasite
```
or using `pyproject.toml`:
```toml
[tool.poetry.dependencies]
parasite = "^0.1.0"
```
### Example usage
```python
from parasite import p
schema = p.obj({
"name": p.string().required(),
"age": p.number().integer().min(0).optional(),
}).strip()
data = {
"name": "John Doe",
"age": 42,
"extra": "This will be stripped",
}
schema.parse(data) # {"name": "John Doe", "age": 42}
schema.parse({}) # ValidationError: Missing required key: "name"
```
## Documentation
> [!IMPORTANT]
>
> You can find the sphinx online documentation [here](https://hendrikboeck.github.io/parasite)!
## Code Coverage
```
---------- coverage: platform linux, python 3.11.9-final-0 -----------
Name Stmts Miss Cover
----------------------------------------------
src/parasite/__init__.py 22 0 100%
src/parasite/_const.py 17 0 100%
src/parasite/_utils.py 7 0 100%
src/parasite/any.py 27 0 100%
src/parasite/array.py 70 0 100%
src/parasite/boolean.py 72 0 100%
src/parasite/errors.py 1 0 100%
src/parasite/never.py 18 0 100%
src/parasite/null.py 29 0 100%
src/parasite/number.py 106 0 100%
src/parasite/object.py 93 0 100%
src/parasite/string.py 207 0 100%
src/parasite/type.py 29 0 100%
src/parasite/variant.py 61 0 100%
----------------------------------------------
TOTAL 759 0 100%
```
## License (_MIT License_)
Copyright (c) 2024, Hendrik Böck <<hendrikboeck.dev@protonmail.com>>
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.
[license-shield]: https://img.shields.io/github/license/hendrikboeck/parasite?style=for-the-badge
[license-url]: https://github.com/hendrikboeck/parasite/blob/main/LICENSE
[issues-shield]: https://img.shields.io/github/issues/hendrikboeck/parasite?style=for-the-badge
[issues-url]: https://github.com/hendrikboeck/parasite/issues
[forks-shield]: https://img.shields.io/github/forks/hendrikboeck/parasite?style=for-the-badge
[forks-url]: https://github.com/hendrikboeck/parasite/forks
[contributors-shield]: https://img.shields.io/github/contributors/hendrikboeck/parasite?style=for-the-badge
[contributors-url]: https://github.com/hendrikboeck/parasite/contributors
[stars-shield]: https://img.shields.io/github/stars/hendrikboeck/parasite?style=for-the-badge
[coverage-shield]: https://img.shields.io/badge/Code%20Coverage-100%25-brightgreen.svg?style=for-the-badge
Raw data
{
"_id": null,
"home_page": "https://hendrikboeck.github.io/parasite",
"name": "parasite",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.11",
"maintainer_email": null,
"keywords": "data, validation, python, zod, datastructures, types, objects, schema, runtime-evaluation",
"author": "Hendrik Boeck",
"author_email": "hendrikboeck.dev@protonmail.com",
"download_url": "https://files.pythonhosted.org/packages/46/28/9d12877c0a2e84085767b64559bc76d892bf0df26528255a0963348bf718/parasite-0.1.10.tar.gz",
"platform": null,
"description": "![Stars][stars-shield]\n[![Contributors][contributors-shield]][contributors-url]\n[![Forks][forks-shield]][forks-url]\n[![Issues][issues-shield]][issues-url]\n[![MIT License][license-shield]][license-url]\n[![Code Coverage][coverage-shield]](#code-coverage)\n\n\n<br />\n<div align=\"center\">\n<a href=\"https://github.com/hendrikboeck/parasite\">\n <img src=\"https://raw.githubusercontent.com/hendrikboeck/parasite/main/.github/parasite_logo.png\" alt=\"Logo\" width=\"128\" height=\"128\">\n</a>\n\n<h1 align=\"center\">parasite <code>v0.1.10</code></h1>\n\n<p align=\"center\">\n <code>zod</code> inspired library for Python 3.11+\n <br />\n <a href=\"https://github.com/hendrikboeck/parasite/issues/new?labels=bug&template=bug-report---.md\">Report Bug</a>\n |\n <a href=\"https://github.com/ohendrikboeck/parasite/issues/new?labels=enhancement&template=feature-request---.md\">Request Feature</a>\n</p>\n</div>\n\n> [!WARNING]\n>\n> This library is under active development, expect things to break or not to work as expected.\n> Creating an issue for bugs you encounter would be appreciated. Documentation is currently work in\n> progress.\n\n## Table of Contents\n\n- [Why?](#why)\n- [What about the name?](#what-about-the-name)\n- [Getting Started](#getting-started)\n - [Installing](#installing)\n - [Example usage](#example-usage)\n- [Documentation](#documentation)\n- [Code Coverage](#code-coverage)\n- [License (_MIT License_)](#license-mit-license)\n\n## Why?\n\nData and object validation in Python is essential to ensure that the inputs to a program are\naccurate and adhere to expected formats, thereby preventing runtime errors and enhancing code\nreliability. The TypeScript library `zod` offers a concise and expressive syntax for schema\nvalidation, making it easier to define and enforce data structures. Implementing a similar library\nin Python would greatly benefit developers by providing a streamlined, declarative approach to\nvalidation, reducing boilerplate code and improving maintainability. This would facilitate more\nrobust data handling and enhance the overall quality of Python applications.\n\n## What about the name?\n\nI chose the name \"Parasite\" for this library because it draws heavy inspiration from the TypeScript\n`zod` library, which excels in schema validation with its concise and expressive syntax. The name\n\"Parasite\" is also a nod to one of Superman's iconic supervillains, serving as an homage to the\nlibrary that inspired this creation.\n\n## Getting Started\n\n### Installing\n\nInstall using `pip`:\n\n```sh\npip install parasite\n```\n\nInstall using `poetry` CLI:\n\n```sh\npoetry add parasite\n```\n\nor using `pyproject.toml`:\n\n```toml\n[tool.poetry.dependencies]\nparasite = \"^0.1.0\"\n```\n\n### Example usage\n\n```python\nfrom parasite import p\n\nschema = p.obj({\n \"name\": p.string().required(),\n \"age\": p.number().integer().min(0).optional(),\n}).strip()\n\ndata = {\n \"name\": \"John Doe\",\n \"age\": 42,\n \"extra\": \"This will be stripped\",\n}\n\nschema.parse(data) # {\"name\": \"John Doe\", \"age\": 42}\nschema.parse({}) # ValidationError: Missing required key: \"name\"\n```\n\n## Documentation\n\n> [!IMPORTANT]\n>\n> You can find the sphinx online documentation [here](https://hendrikboeck.github.io/parasite)!\n\n## Code Coverage\n\n\n\n```\n---------- coverage: platform linux, python 3.11.9-final-0 -----------\nName Stmts Miss Cover\n----------------------------------------------\nsrc/parasite/__init__.py 22 0 100%\nsrc/parasite/_const.py 17 0 100%\nsrc/parasite/_utils.py 7 0 100%\nsrc/parasite/any.py 27 0 100%\nsrc/parasite/array.py 70 0 100%\nsrc/parasite/boolean.py 72 0 100%\nsrc/parasite/errors.py 1 0 100%\nsrc/parasite/never.py 18 0 100%\nsrc/parasite/null.py 29 0 100%\nsrc/parasite/number.py 106 0 100%\nsrc/parasite/object.py 93 0 100%\nsrc/parasite/string.py 207 0 100%\nsrc/parasite/type.py 29 0 100%\nsrc/parasite/variant.py 61 0 100%\n----------------------------------------------\nTOTAL 759 0 100%\n```\n\n\n## License (_MIT License_)\n\nCopyright (c) 2024, Hendrik B\u00f6ck <<hendrikboeck.dev@protonmail.com>>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n[license-shield]: https://img.shields.io/github/license/hendrikboeck/parasite?style=for-the-badge\n[license-url]: https://github.com/hendrikboeck/parasite/blob/main/LICENSE\n[issues-shield]: https://img.shields.io/github/issues/hendrikboeck/parasite?style=for-the-badge\n[issues-url]: https://github.com/hendrikboeck/parasite/issues\n[forks-shield]: https://img.shields.io/github/forks/hendrikboeck/parasite?style=for-the-badge\n[forks-url]: https://github.com/hendrikboeck/parasite/forks\n[contributors-shield]: https://img.shields.io/github/contributors/hendrikboeck/parasite?style=for-the-badge\n[contributors-url]: https://github.com/hendrikboeck/parasite/contributors\n[stars-shield]: https://img.shields.io/github/stars/hendrikboeck/parasite?style=for-the-badge\n[coverage-shield]: https://img.shields.io/badge/Code%20Coverage-100%25-brightgreen.svg?style=for-the-badge\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Data validation for Python 3",
"version": "0.1.10",
"project_urls": {
"Documentation": "https://hendrikboeck.github.io/parasite",
"Homepage": "https://hendrikboeck.github.io/parasite",
"Repository": "https://github.com/hendrikboeck/parasite"
},
"split_keywords": [
"data",
" validation",
" python",
" zod",
" datastructures",
" types",
" objects",
" schema",
" runtime-evaluation"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1ff3d557f8ccb7ba0df4c8595a52b3102db99d7f4ad3f7e3083e4696db8fc814",
"md5": "32f335a00d5acf879a123370ef14181a",
"sha256": "c07df18f16acaf03a3e018eca21466255795ed9bd83cb8c5bf0ace2a9d3e6682"
},
"downloads": -1,
"filename": "parasite-0.1.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "32f335a00d5acf879a123370ef14181a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.11",
"size": 27723,
"upload_time": "2024-07-04T11:08:55",
"upload_time_iso_8601": "2024-07-04T11:08:55.678327Z",
"url": "https://files.pythonhosted.org/packages/1f/f3/d557f8ccb7ba0df4c8595a52b3102db99d7f4ad3f7e3083e4696db8fc814/parasite-0.1.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "46289d12877c0a2e84085767b64559bc76d892bf0df26528255a0963348bf718",
"md5": "6f0366b1f5937ef738b913ffd9d07242",
"sha256": "f919a69565c6c09ca48c460dd0f873c754605b7bba3d4e171921a91551d37f58"
},
"downloads": -1,
"filename": "parasite-0.1.10.tar.gz",
"has_sig": false,
"md5_digest": "6f0366b1f5937ef738b913ffd9d07242",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.11",
"size": 20122,
"upload_time": "2024-07-04T11:08:57",
"upload_time_iso_8601": "2024-07-04T11:08:57.147959Z",
"url": "https://files.pythonhosted.org/packages/46/28/9d12877c0a2e84085767b64559bc76d892bf0df26528255a0963348bf718/parasite-0.1.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-04 11:08:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hendrikboeck",
"github_project": "parasite",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "parasite"
}