Metadata-Version: 2.1
Name: datacast
Version: 0.3.0
Summary: Simple way to cast your data.
Home-page: https://github.com/fatemonk/datacast
Author: Alexander Rulkov
Author-email: fatemonk@gmail.com
License: MIT
Keywords: config,env,data,cast
Platform: UNKNOWN
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Requires-Python: >=3.3

*Datacast* is a Python package that validates and converts your data.

----

|pypi| |python_version| |coverage| |license|

----

Basic Usage
-----------

Install with pip:

.. code:: bash

    pip install datacast


Define schema (can be any class with annotations) and use ``cast`` function.

.. code:: python

    from datacast import cast

    class SimpleSchema:
        zero: bool
        one: int
        two: str
        three: float = 0.3
        four: None = 'four'


    cast({'zero': 0, 'one': 1, 'two': 2, 'four': 5}, SimpleSchema)
    # {'zero': False, 'one': 1, 'two': '2', 'three': 0.3, 'four': 5}

Rules are simple:

-  Annotation is a *caster*, which will be called with the provided value, eg. ``bool(0)``.
-  If no default value is provided, the ``RequiredFieldError`` will be raised.
-  ``None`` in annotation means no casting.


Settings
---------

To be added.

.. |pypi| image:: https://img.shields.io/pypi/v/datacast.svg?style=flat-square&label=version
    :target: https://pypi.org/project/datacast
    :alt: Latest version released on PyPI

.. |python_version| image:: https://img.shields.io/badge/python-%3E%3D3.3-blue.svg?style=flat-square
    :alt: Minimal Python version

.. |coverage| image:: https://img.shields.io/badge/coverage-86%25-yellowgreen.svg?style=flat-square
    :alt: Test coverage

.. |license| image:: https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square
    :target: https://raw.githubusercontent.com/fatemonk/datacast/master/LICENSE
    :alt: Package license


