modelity


Namemodelity JSON
Version 0.7.0 PyPI version JSON
download
home_pagehttps://github.com/mwiatrzyk/modelity
SummaryData parsing and validation library for Python
upload_time2024-11-14 18:54:29
maintainerNone
docs_urlNone
authorMaciej Wiatrzyk
requires_python<4,>=3.9
licenseMIT
keywords parsing validation modelling parser validator model library toolkit
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # modelity

Data parsing and validation library for Python.

## About

Modelity is a data parsing and validation library allowing to declare mutable
data models using Python's type hinting mechanism. Modelity design was based on
following assumptions:

* Use of recursive **type parser providers**, allowing to create parsers for
  both built-in types, and user-defined ones.

* Use of cache mechanism, so type parser created once can be reused by other
  models, or other fields.

* Clean separation between **data parsing** and **model validation** steps,
  with automatic data parsing whenever model is created or modified, and
  validation phase being executed on user's demand.

* Separation between model-scoped validators (executed always) and field-scoped
  validators (executed for selected fields and only if the field has value
  set).

* Ability to inspect entire model when validating it, even from a nested model.

* Use of separate ``Unset`` type to differentiate between fields set to
  ``None`` and fields that are unset.

* Easily customized with user-defined parsing and/or validation hooks provided
  by decorators.

* Models are mutable, so modifying a field after model is created, appending a
  value to typed list field etc. invokes parsing mechanism, keeping integrity
  of the entire model.

## Rationale

Why I have created this toolkit?

Well, for fun, that's for sure :-)

I also wanted to resurrect some ideas from my over 10-year old and abandoned
project Formify (which you can still find on my GH profile), as it was already
supplied with data parsing and validation separation mechanism. Unfortunately,
the name Formify was already in use (as I have never released it), so I've
decided to go with a completely new project name.

And last but not least - the separation of concerns (**parsing** and
**validation**) is the feature that I needed in several projects, both private
and commercial, and that I did not find in any toolkit I've been using, forcing
me to subclassing and/or creating separate project-specific tools to make
validation being separate from data parsing. I needed this especially for large
models, with lots of nested submodels, that could not be easily validated
without being able to inspect entire model tree (f.e. when validity of nested
model depends on a value of particular parent model field).

## Usage

I will create a separate guide in the future, but for now please check out the
examples directly in the source code:

https://github.com/mwiatrzyk/modelity/tree/main/tests/examples

## License

This project is released under the terms of the MIT license.

## Author

Maciej Wiatrzyk <maciej.wiatrzyk@gmail.com>

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mwiatrzyk/modelity",
    "name": "modelity",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.9",
    "maintainer_email": null,
    "keywords": "parsing, validation, modelling, parser, validator, model, library, toolkit",
    "author": "Maciej Wiatrzyk",
    "author_email": "maciej.wiatrzyk@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/29/a2/f0a68d38c1be14a333480cad5c3bdb5f9218031e7492f7e37eca081654dc/modelity-0.7.0.tar.gz",
    "platform": null,
    "description": "# modelity\n\nData parsing and validation library for Python.\n\n## About\n\nModelity is a data parsing and validation library allowing to declare mutable\ndata models using Python's type hinting mechanism. Modelity design was based on\nfollowing assumptions:\n\n* Use of recursive **type parser providers**, allowing to create parsers for\n  both built-in types, and user-defined ones.\n\n* Use of cache mechanism, so type parser created once can be reused by other\n  models, or other fields.\n\n* Clean separation between **data parsing** and **model validation** steps,\n  with automatic data parsing whenever model is created or modified, and\n  validation phase being executed on user's demand.\n\n* Separation between model-scoped validators (executed always) and field-scoped\n  validators (executed for selected fields and only if the field has value\n  set).\n\n* Ability to inspect entire model when validating it, even from a nested model.\n\n* Use of separate ``Unset`` type to differentiate between fields set to\n  ``None`` and fields that are unset.\n\n* Easily customized with user-defined parsing and/or validation hooks provided\n  by decorators.\n\n* Models are mutable, so modifying a field after model is created, appending a\n  value to typed list field etc. invokes parsing mechanism, keeping integrity\n  of the entire model.\n\n## Rationale\n\nWhy I have created this toolkit?\n\nWell, for fun, that's for sure :-)\n\nI also wanted to resurrect some ideas from my over 10-year old and abandoned\nproject Formify (which you can still find on my GH profile), as it was already\nsupplied with data parsing and validation separation mechanism. Unfortunately,\nthe name Formify was already in use (as I have never released it), so I've\ndecided to go with a completely new project name.\n\nAnd last but not least - the separation of concerns (**parsing** and\n**validation**) is the feature that I needed in several projects, both private\nand commercial, and that I did not find in any toolkit I've been using, forcing\nme to subclassing and/or creating separate project-specific tools to make\nvalidation being separate from data parsing. I needed this especially for large\nmodels, with lots of nested submodels, that could not be easily validated\nwithout being able to inspect entire model tree (f.e. when validity of nested\nmodel depends on a value of particular parent model field).\n\n## Usage\n\nI will create a separate guide in the future, but for now please check out the\nexamples directly in the source code:\n\nhttps://github.com/mwiatrzyk/modelity/tree/main/tests/examples\n\n## License\n\nThis project is released under the terms of the MIT license.\n\n## Author\n\nMaciej Wiatrzyk <maciej.wiatrzyk@gmail.com>\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Data parsing and validation library for Python",
    "version": "0.7.0",
    "project_urls": {
        "Homepage": "https://github.com/mwiatrzyk/modelity",
        "Repository": "https://github.com/mwiatrzyk/modelity"
    },
    "split_keywords": [
        "parsing",
        " validation",
        " modelling",
        " parser",
        " validator",
        " model",
        " library",
        " toolkit"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "62e9fde9d2f27be6408aaab8042ee1c85ab94d15ee50102998a7799ec598fa4d",
                "md5": "a66cc419a6aaf0512d2eadcb6cd4f56e",
                "sha256": "21e172028a0f0c9701182293938cee5affbeab154c9c88da643cd26956081242"
            },
            "downloads": -1,
            "filename": "modelity-0.7.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a66cc419a6aaf0512d2eadcb6cd4f56e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.9",
            "size": 33150,
            "upload_time": "2024-11-14T18:54:26",
            "upload_time_iso_8601": "2024-11-14T18:54:26.803842Z",
            "url": "https://files.pythonhosted.org/packages/62/e9/fde9d2f27be6408aaab8042ee1c85ab94d15ee50102998a7799ec598fa4d/modelity-0.7.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "29a2f0a68d38c1be14a333480cad5c3bdb5f9218031e7492f7e37eca081654dc",
                "md5": "6362071b243613226ef61c51f0aa9509",
                "sha256": "21f320cc37c7dc7d17abed9e74b2a8a1994717ff09243d099a05376a0701360e"
            },
            "downloads": -1,
            "filename": "modelity-0.7.0.tar.gz",
            "has_sig": false,
            "md5_digest": "6362071b243613226ef61c51f0aa9509",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.9",
            "size": 22798,
            "upload_time": "2024-11-14T18:54:29",
            "upload_time_iso_8601": "2024-11-14T18:54:29.156191Z",
            "url": "https://files.pythonhosted.org/packages/29/a2/f0a68d38c1be14a333480cad5c3bdb5f9218031e7492f7e37eca081654dc/modelity-0.7.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-14 18:54:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mwiatrzyk",
    "github_project": "modelity",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "circle": true,
    "lcname": "modelity"
}
        
Elapsed time: 0.39821s