{ "info": { "author": "Ben Krikler", "author_email": "b.krikler@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities" ], "description": "[![PyPI version](https://img.shields.io/pypi/v/valleydeight.svg?longCache=true&style=flat-square)](https://pypi.org/project/valleydeight/)\n[![Build Status](https://img.shields.io/travis/benkrikler/valleydeight/master.svg?longCache=true&style=flat-square)](https://travis-ci.org/benkrikler/valleydeight)\n[![codecov](https://img.shields.io/codecov/c/github/benkrikler/valleydeight/master.svg?longCache=true&style=flat-square)](https://codecov.io/gh/benkrikler/valleydeight)\n\nValleydeight\n===========\nPronounced like: \"validate\" _[val-i-deyt]_\n\n***Effective dictionary and nested object validation for Python***\n\nLately, I've found myself writing many YAML-based config files.\nBeing able to quickly and easily put together a schema for these files has become helpful, and the existing options out there were proving awkward to me.\n\nThe approach here is to work directly on the resulting python objects.\nThis allows the code here to be useful in many other situations, and to validate other types of markup easily (eg JSON, XML (?), pickled primitives, etc).\n\n## Installation\n```\npip install --user valleydeight\n```\n\n## Usage\nTo be able to validate an object, you must build up a Validator. Doing this is straight forward for most types.\nThere are currently many types of Validators implemented:\n* Primitive types: `Str`, `Int`, `Float`, `Bool`\n* Lists of items: `List`, `FixedList`\n* Dictionaries of items: `Dict`\n* Mixed types: `Choice`\n* Custom objects: `Object`\n* A validator that accepts everything: `Pass`\n\nTo make a validator, simply instantiate one of the above classes, composing together the more complicated types where needed.\nTo use the validator call it with the object you wish to validate.\n\nFor example, say we wish to check that we have a list of dictionaries where each dictionary has a string called \"name\" and a boolean called \"on\":\n```python\nimport valleydeight as vd\n\n# Build the validator\nvalidator = vd.List(vd.Dict(name=vd.Str(), on=vd.Bool()))\n\n# Make a test object that should pass fine\ntest_object = [dict(name=\"hello\", on=True), dict(name=\"World\", on=False)]\nparsed_object = validator(test_object)\n\n# Make a test object that will fail, since one of the elements has the wrong type:\ntest_object = [dict(name=\"hello\", on=True), dict(name=\"World\", on=2018)]\nparsed_object = validator(test_object)\n# Raises ValidatorException\n```\n\nThe `Choice` class allows us to make complicated \"custom\" types:\n```python\nimport valleydeight as vd\n\n# Something like a pythonic Enum with mixed types:\nenum_t = vd.Choice(\"one\", 4, True)\n\n# A mixture of validator types:\nmix_t = vd.Choice(vd.Str(), vd.Dict(name=vd.Str(), value=vd.Pass()).opts(need_all_keys=True))\n\n# A mixture of specific values and generic types\nmix_t = vd.Choice(10012, False, vd.Str(), vd.List(vd.Float()))\n```\n\nThe difference between a `List` and a `FixedList` is that a `List` allows an\narbitrary number of items, which must all be the same type (although this can\nbe a `Choice` type), whereas a `FixedList` has both a fixed length and specific types for each element.\n\n## Example program\nFor an example program see the script in the [`examples/`](https://github.com/benkrikler/valleydeight/tree/master/examples) directory on GitHub.\nIn addition the unit tests in the [`tests/`](https://github.com/benkrikler/valleydeight/tree/master/tests) directory might be informative.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/benkrikler/valleydeight", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "valleydeight", "package_url": "https://pypi.org/project/valleydeight/", "platform": "", "project_url": "https://pypi.org/project/valleydeight/", "project_urls": { "Homepage": "https://github.com/benkrikler/valleydeight" }, "release_url": "https://pypi.org/project/valleydeight/0.0.4/", "requires_dist": [ "six", "pyyaml" ], "requires_python": "", "summary": "Effective dictionary and nested object validation", "version": "0.0.4" }, "last_serial": 4855264, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "34971a90ad927cadd9c2f2c9581cae39", "sha256": "d12cdafb3ecc0fc6c316c21e81663d08eebe3d863435a95d279f8012adbdb834" }, "downloads": -1, "filename": "valleydeight-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "34971a90ad927cadd9c2f2c9581cae39", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6142, "upload_time": "2018-06-12T22:58:28", "url": "https://files.pythonhosted.org/packages/14/7c/ad0ded7c75539aacc344b4243706f76936eb8bbdd224b2782b3f0109568c/valleydeight-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "36b483ac9f9e65c31ab8db1d53156d27", "sha256": "a0847e1790ca6bd7cc3efb720d4f725df3b6076151afb1237aa04cd12f897083" }, "downloads": -1, "filename": "valleydeight-0.0.1.tar.gz", "has_sig": false, "md5_digest": "36b483ac9f9e65c31ab8db1d53156d27", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4281, "upload_time": "2018-06-12T22:58:29", "url": "https://files.pythonhosted.org/packages/f4/e6/f128868faba9e5e93d54b2b24dd02a5e470ec5139ed1bb74bcf450fd8493/valleydeight-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "cd7deca2cdcee44cad3e97b85a03c96c", "sha256": "047091a11f8fc5572046722cd5e84c1bddd7602e176619ca94135226932ab21c" }, "downloads": -1, "filename": "valleydeight-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "cd7deca2cdcee44cad3e97b85a03c96c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6215, "upload_time": "2018-06-12T23:42:35", "url": "https://files.pythonhosted.org/packages/39/ca/231bfc40098950052431273f7951ba39ac72930a1fdea7029c981a86eb21/valleydeight-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f2a4696eb2f0d7be82d714a1d17954db", "sha256": "db535668612bfaae2381d3500870fa0573388379c745fdf5d8c0c7a83858f04e" }, "downloads": -1, "filename": "valleydeight-0.0.2.tar.gz", "has_sig": false, "md5_digest": "f2a4696eb2f0d7be82d714a1d17954db", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4397, "upload_time": "2018-06-12T23:42:36", "url": "https://files.pythonhosted.org/packages/5e/99/94063fc96cea0f7d162656131a9e07d611082744e5354b1ef066445a72c9/valleydeight-0.0.2.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "da381c96cd056e2ecda666eada4b8266", "sha256": "b3146d07bba7c9d1fbc4fb38886dda6b9999cad75071ed363359af734d3f8a1c" }, "downloads": -1, "filename": "valleydeight-0.0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "da381c96cd056e2ecda666eada4b8266", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7080, "upload_time": "2019-02-22T17:12:08", "url": "https://files.pythonhosted.org/packages/1c/5b/47c173377dc3d521636e86720e00677fa84fc5c1a5230cae4305f92b8682/valleydeight-0.0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7df76c5e61157d212c0210eb2383bdc6", "sha256": "9c67f97e80463218beeebef07b59b536c1ef03470d3ead719da9a9257b70b1d2" }, "downloads": -1, "filename": "valleydeight-0.0.4.tar.gz", "has_sig": false, "md5_digest": "7df76c5e61157d212c0210eb2383bdc6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4639, "upload_time": "2019-02-22T17:12:10", "url": "https://files.pythonhosted.org/packages/42/03/912ddbeb346f8e013e52bf291cfa1a1e2c865a892a7f654c825231bf5088/valleydeight-0.0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "da381c96cd056e2ecda666eada4b8266", "sha256": "b3146d07bba7c9d1fbc4fb38886dda6b9999cad75071ed363359af734d3f8a1c" }, "downloads": -1, "filename": "valleydeight-0.0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "da381c96cd056e2ecda666eada4b8266", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7080, "upload_time": "2019-02-22T17:12:08", "url": "https://files.pythonhosted.org/packages/1c/5b/47c173377dc3d521636e86720e00677fa84fc5c1a5230cae4305f92b8682/valleydeight-0.0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7df76c5e61157d212c0210eb2383bdc6", "sha256": "9c67f97e80463218beeebef07b59b536c1ef03470d3ead719da9a9257b70b1d2" }, "downloads": -1, "filename": "valleydeight-0.0.4.tar.gz", "has_sig": false, "md5_digest": "7df76c5e61157d212c0210eb2383bdc6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4639, "upload_time": "2019-02-22T17:12:10", "url": "https://files.pythonhosted.org/packages/42/03/912ddbeb346f8e013e52bf291cfa1a1e2c865a892a7f654c825231bf5088/valleydeight-0.0.4.tar.gz" } ] }