typing-validation: Validation using Type Hints
==============================================
.. image:: https://img.shields.io/badge/python-3.7+-green.svg
:target: https://docs.python.org/3.7/
:alt: Python versions
.. image:: https://img.shields.io/pypi/v/typing-validation.svg
:target: https://pypi.python.org/pypi/typing-validation/
:alt: PyPI version
.. image:: https://img.shields.io/pypi/status/typing-validation.svg
:target: https://pypi.python.org/pypi/typing-validation/
:alt: PyPI status
.. image:: http://www.mypy-lang.org/static/mypy_badge.svg
:target: https://github.com/python/mypy
:alt: Checked with Mypy
.. image:: https://readthedocs.org/projects/typing-validation/badge/?version=latest
:target: https://typing-validation.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
.. image:: https://github.com/hashberg-io/typing-validation/actions/workflows/python-pytest.yml/badge.svg
:target: https://github.com/hashberg-io/typing-validation/actions/workflows/python-pytest.yml
:alt: Python package status
.. image:: https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square
:target: https://github.com/RichardLitt/standard-readme
:alt: standard-readme compliant
Typing-validation is a small library to perform runtime validation of Python objects using `PEP 484 type hints <https://www.python.org/dev/peps/pep-0484/>`_.
This is a temporary fork of the original project to be used until the original project incorporates a bug fix to work with newer versions of the 'typing_extensions' dependency.
Bug: https://github.com/hashberg-io/typing-validation/issues/1
.. contents::
Install
-------
You can install the latest release from `PyPI <https://pypi.org/project/multiformats/>`_ as follows:
.. code-block::
pip install --upgrade typing-validation
Usage
-----
The core functionality of this library is provided by the `validate` function:
>>> from typing_validation import validate
The `validate` function is invoked with a value and a type as its arguments and it returns nothing when the given value is valid for the given type:
>>> validate(12, int)
# nothing is returned => 12 is a valid int
If the value is invalid for the given type, the `validate` function raises a `TypeError`:
>>> validate(12, str)
TypeError: For type <class 'str'>, invalid value: 12
For nested types (e.g. parametric collection/mapping types), the full chain of validation failures is shown by the type error:
>>> validate([0, 1, "hi"], list[int])
TypeError: For type list[int], invalid value: [0, 1, 'hi']
For type <class 'int'>, invalid value: 'hi'
API
---
For the full API documentation, see https://typing-validation.readthedocs.io/
Contributing
------------
Please see `<CONTRIBUTING.md>`_.
License
-------
`MIT © Hashberg Ltd. <LICENSE>`_
Raw data
{
"_id": null,
"home_page": "https://github.com/hashberg-io/typing-validation",
"name": "makkus.typing-validation",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "",
"author": "hashberg",
"author_email": "sg495@users.noreply.github.com",
"download_url": "https://files.pythonhosted.org/packages/28/46/df84c4a56b992ab05601b897782aa52bbc7065c665f826ca4f245844f6f3/makkus.typing-validation-1.0.3.tar.gz",
"platform": null,
"description": "\ntyping-validation: Validation using Type Hints\n==============================================\n\n.. image:: https://img.shields.io/badge/python-3.7+-green.svg\n :target: https://docs.python.org/3.7/\n :alt: Python versions\n\n.. image:: https://img.shields.io/pypi/v/typing-validation.svg\n :target: https://pypi.python.org/pypi/typing-validation/\n :alt: PyPI version\n\n.. image:: https://img.shields.io/pypi/status/typing-validation.svg\n :target: https://pypi.python.org/pypi/typing-validation/\n :alt: PyPI status\n\n.. image:: http://www.mypy-lang.org/static/mypy_badge.svg\n :target: https://github.com/python/mypy\n :alt: Checked with Mypy\n \n.. image:: https://readthedocs.org/projects/typing-validation/badge/?version=latest\n :target: https://typing-validation.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation Status\n\n.. image:: https://github.com/hashberg-io/typing-validation/actions/workflows/python-pytest.yml/badge.svg\n :target: https://github.com/hashberg-io/typing-validation/actions/workflows/python-pytest.yml\n :alt: Python package status\n\n.. image:: https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square\n :target: https://github.com/RichardLitt/standard-readme\n :alt: standard-readme compliant\n\nTyping-validation is a small library to perform runtime validation of Python objects using `PEP 484 type hints <https://www.python.org/dev/peps/pep-0484/>`_.\n\n\nThis is a temporary fork of the original project to be used until the original project incorporates a bug fix to work with newer versions of the 'typing_extensions' dependency.\n\nBug: https://github.com/hashberg-io/typing-validation/issues/1\n\n.. contents::\n\n\nInstall\n-------\n\nYou can install the latest release from `PyPI <https://pypi.org/project/multiformats/>`_ as follows:\n\n.. code-block::\n\n pip install --upgrade typing-validation\n\n\nUsage\n-----\n\nThe core functionality of this library is provided by the `validate` function:\n\n\n>>> from typing_validation import validate\n\nThe `validate` function is invoked with a value and a type as its arguments and it returns nothing when the given value is valid for the given type:\n\n>>> validate(12, int)\n# nothing is returned => 12 is a valid int\n\nIf the value is invalid for the given type, the `validate` function raises a `TypeError`:\n\n>>> validate(12, str)\nTypeError: For type <class 'str'>, invalid value: 12\n\nFor nested types (e.g. parametric collection/mapping types), the full chain of validation failures is shown by the type error:\n\n>>> validate([0, 1, \"hi\"], list[int])\nTypeError: For type list[int], invalid value: [0, 1, 'hi']\n For type <class 'int'>, invalid value: 'hi'\n\n\nAPI\n---\n\nFor the full API documentation, see https://typing-validation.readthedocs.io/\n\n\nContributing\n------------\n\nPlease see `<CONTRIBUTING.md>`_.\n\n\nLicense\n-------\n\n`MIT \u00a9 Hashberg Ltd. <LICENSE>`_\n",
"bugtrack_url": null,
"license": "",
"summary": "Forked from the original author until they incorporate latest fixes; a simple library for runtime type-checking.",
"version": "1.0.3",
"project_urls": {
"Bug Tracker": "https://github.com/hashberg-io/typing-validation/issues",
"Homepage": "https://github.com/hashberg-io/typing-validation"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "cacb7755ab1bc56cc921e7c1fee6fcdbaf2cc04f852576e7b51a5feb6fbd3a16",
"md5": "ba0ddb59c8568a58525c41ee7f1437ab",
"sha256": "c08293fc2f95fd9f0f888b43838f777d3d8b7b7692b2ec987da5c93c17d26611"
},
"downloads": -1,
"filename": "makkus.typing_validation-1.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ba0ddb59c8568a58525c41ee7f1437ab",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 13709,
"upload_time": "2023-11-28T09:16:41",
"upload_time_iso_8601": "2023-11-28T09:16:41.876621Z",
"url": "https://files.pythonhosted.org/packages/ca/cb/7755ab1bc56cc921e7c1fee6fcdbaf2cc04f852576e7b51a5feb6fbd3a16/makkus.typing_validation-1.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2846df84c4a56b992ab05601b897782aa52bbc7065c665f826ca4f245844f6f3",
"md5": "ce13262860c1d23787367b41f7a8f3b0",
"sha256": "1d3df269bfcebeb02138c3a165fe7e55b1d490792fc80dba501c39cb51e7fd3d"
},
"downloads": -1,
"filename": "makkus.typing-validation-1.0.3.tar.gz",
"has_sig": false,
"md5_digest": "ce13262860c1d23787367b41f7a8f3b0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 29605,
"upload_time": "2023-11-28T09:16:43",
"upload_time_iso_8601": "2023-11-28T09:16:43.465297Z",
"url": "https://files.pythonhosted.org/packages/28/46/df84c4a56b992ab05601b897782aa52bbc7065c665f826ca4f245844f6f3/makkus.typing-validation-1.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-28 09:16:43",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hashberg-io",
"github_project": "typing-validation",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"tox": true,
"lcname": "makkus.typing-validation"
}