{ "info": { "author": "Vaidik Kapoor", "author_email": "kapoor.vaidik@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 1 - Planning", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python" ], "description": "incoming: JSON validation framework for Python\n==============================================\n\n**incoming** is a JSON validation framework.\n\n|Build Status| |Coverage Status|\n\n.. |Build Status| image:: https://travis-ci.org/vaidik/incoming.png\n :target: https://travis-ci.org/vaidik/incoming\n.. |Coverage Status| image:: https://coveralls.io/repos/vaidik/incoming/badge.png?branch=master\n :target: https://coveralls.io/r/vaidik/incoming?branch=master\n\nOverview\n--------\n\nValidating anything can get really messy. JSON being one of the most used\nformats for data exchange, **incoming** aims at solving the problem of\nvalidating JSON with structure and ease.\n\n**incoming** is a small framework for validating JSON. It's up to you where and\nhow to use it. A common use-case (and the primary reason why I wrote this\nframework) is validating incoming JSON when writing HTTP servers.\n\nFeatures\n++++++++\n\n* Classes that can be sub-classed for writing structured validators.\n* Basic validators (or `datatypes`) for performing common validations, like\n string, numbers, booleans, lists, nested JSON, etc.\n* Allows extending validators (`datatypes`) to write your own.\n* Allows writing callables for validating values.\n* Captures errors during validation and returns a complete report of errors.\n* Allows reporting different errors for different validation test failures for\n the same value.\n\nInstallation\n------------\n\nInstallation is simple.\n\n.. code:: bash\n\n pip install incoming\n\nBasic Usage\n-----------\n\n.. code-block:: python\n\n import json\n\n from datetime import date\n from incoming import datatypes, PayloadValidator\n\n\n class MovieValidator(PayloadValidator):\n name = datatypes.String()\n rating = datatypes.Function(\n 'validate_rating',\n error='Rating must be in between 1 and 10.',\n )\n actors = datatypes.Array()\n is_3d = datatypes.Boolean()\n release_year = datatypes.Function(\n 'validate_release_year',\n error='Release year must be in between 1800 and current year.',\n )\n\n # validation method can be a regular method\n def validate_rating(self, val, *args, **kwargs):\n return isinstance(val, int) and val >= 1 and val <= 10\n\n # validation method can be a staticmethod as well\n @staticmethod\n def validate_release_year(val, *args, **kwargs):\n return all((\n isinstance(val, int),\n val >= 1800,\n val <= date.today().year,\n ))\n\n payload = {\n 'name': 'Avengers',\n 'rating': 5,\n 'actors': [\n 'Robert Downey Jr.',\n 'Samuel L. Jackson',\n 'Scarlett Johansson',\n 'Mark Ruffalo'\n ],\n 'is_3d': True,\n 'release_year': 2012\n }\n result, errors = MovieValidator().validate(payload)\n assert result and errors is None, 'Validation failed.\\n%s' % json.dumps(errors, indent=2)\n\n payload = {\n 'name': 'Avengers',\n 'rating': 11,\n 'actors': [\n 'Robert Downey Jr.',\n 'Samuel L. Jackson',\n 'Scarlett Johansson',\n 'Mark Ruffalo'\n ],\n 'is_3d': 'True',\n 'release_year': 9000\n }\n result, errors = MovieValidator().validate(payload)\n assert result and errors is None, 'Validation failed.\\n%s' % json.dumps(errors, indent=2)\n\nIf you run the above script, you will get::\n\n Traceback (most recent call last):\n File \"code.py\", line 67, in \n assert result and errors is None, 'Validation failed.\\n%s' % json.dumps(errors, indent=2)\n AssertionError: Validation failed.\n {\n \"rating\": [\n \"Rating must be in between 1 and 10.\"\n ],\n \"is_3d\": [\n \"Invalid data. Expected a boolean value.\"\n ],\n \"release_year\": [\n \"Release year must be in between 1800 and current year.\"\n ]\n }\n\nDocumentation\n-------------\n\nDocumentation is available on `Read The Docs`_.\n\n.. _Read The Docs: http://incoming.readthedocs.org/en/latest/\n\nTests\n-----\n\nSimply run::\n\n python setup.py test\n\nor::\n\n py.test incoming\n\nContributors\n------------\n\n- `Vaidik Kapoor `_ (Author)\n- `Dhruv Baldawa `_\n- `James Rowe `_\n\nLicence\n-------\n\nSee `LICENCE`_.\n\n.. _LICENCE: https://github.com/vaidik/incoming/blob/master/LICENSE\n\n\nThe MIT License (MIT)\n\nCopyright (c) 2013 Vaidik Kapoor\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject 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, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\nCHANGELOG\n---------\n\nDevelopment Version\n+++++++++++++++++++\n\n0.3.1\n*****\n\n* Documentation changes on using Nested JSON validators. Passing name of nested\n class to `incoming.datatypes.JSON` is now discouraged. This means that the\n inner class has to be correctly scoped. `Read more here `__.\n\n0.3.0\n*****\n\n* Pass only the error list of a field in payload to its validator method.\n* Pass errors and payload as keyword arguments.\n* For fields that are not required and have Function as their type, call the\n validation method/function even if the field is missing in payload.\n\n0.2.6\n*****\n\n* Support Python 3.\n\n0.2.5\n*****\n\n* Abstract out datatypes that perform just Python type checks to reduce code.\n\n0.2.4\n*****\n\n* Fix tests for Python 2.5 and 2.6. Fix README.\n\n0.2.3\n*****\n\n* Package setup changes - added classifiers and manifest file.\n\n0.2.1\n*****\n\n* First public release of Incoming.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/vaidik/incoming", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "incoming", "package_url": "https://pypi.org/project/incoming/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/incoming/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/vaidik/incoming" }, "release_url": "https://pypi.org/project/incoming/0.3.1/", "requires_dist": null, "requires_python": null, "summary": "JSON validation framework for Python.", "version": "0.3.1" }, "last_serial": 1495339, "releases": { "0.2.2": [ { "comment_text": "built for Darwin-12.4.0", "digests": { "md5": "b37f6f25d6d909ccecb3c05def8320d3", "sha256": "29b54f8052bdea8413ab21b24775aa7a05c0a68edacc6912e371cdac5fba4475" }, "downloads": -1, "filename": "incoming-0.2.2.macosx-10.8-intel.tar.gz", "has_sig": false, "md5_digest": "b37f6f25d6d909ccecb3c05def8320d3", "packagetype": "bdist_dumb", "python_version": "any", "requires_python": null, "size": 18760, "upload_time": "2013-10-06T08:23:17", "url": "https://files.pythonhosted.org/packages/e3/4e/19b0fd1fa184542ee8b06c7812d65dca23f01f934f1743e21a0a1f30ca85/incoming-0.2.2.macosx-10.8-intel.tar.gz" }, { "comment_text": "", "digests": { "md5": "041d864d60f026ba5022540959e73501", "sha256": "e060f278d25fc0ab185a56eb0945365a643c3e83e49ec1be55a48509294bda68" }, "downloads": -1, "filename": "incoming-0.2.2.tar.gz", "has_sig": false, "md5_digest": "041d864d60f026ba5022540959e73501", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9951, "upload_time": "2013-10-06T08:20:00", "url": "https://files.pythonhosted.org/packages/51/d6/01d7ee1e03820156838f2e8feaae30a19a9bfa4ff85f3253284f39757784/incoming-0.2.2.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "95e7d70234bf75bb4f3472b4dae5ca37", "sha256": "5026e50f4cfe7cb85becb9aa0ebb0c6d1a37cf5d7669e02727c0f008c3b8e81a" }, "downloads": -1, "filename": "incoming-0.2.3.tar.gz", "has_sig": false, "md5_digest": "95e7d70234bf75bb4f3472b4dae5ca37", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10139, "upload_time": "2013-10-06T08:31:51", "url": "https://files.pythonhosted.org/packages/ce/29/866b578527c9338f2fe82a3f530308d9dbb0edaaf0fc7299791a5082e046/incoming-0.2.3.tar.gz" } ], "0.2.4": [ { "comment_text": "", "digests": { "md5": "ffbb309fc1288a0fb4fb79e61036090f", "sha256": "acae87e6dfe73f0090e2857a3b95cb0dfcf915fe116d69825bc887187fdf5848" }, "downloads": -1, "filename": "incoming-0.2.4.tar.gz", "has_sig": false, "md5_digest": "ffbb309fc1288a0fb4fb79e61036090f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10441, "upload_time": "2013-10-07T03:58:57", "url": "https://files.pythonhosted.org/packages/66/f3/47f92e4b6b2167e3a497f93bf42cf5707ef69db9f74b1aee4068a6fc4941/incoming-0.2.4.tar.gz" } ], "0.2.5": [ { "comment_text": "", "digests": { "md5": "1a13e6784f3b023abbc7d6d856e22acc", "sha256": "2a5c6fa77044c223a2c52dd3010b373e47d13711dbcf11096b7e90b8e0efd268" }, "downloads": -1, "filename": "incoming-0.2.5.tar.gz", "has_sig": false, "md5_digest": "1a13e6784f3b023abbc7d6d856e22acc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10850, "upload_time": "2013-10-07T09:24:45", "url": "https://files.pythonhosted.org/packages/12/bc/3f93d22a23b7445fd14e28526016e2cd475799ab7a3f5d14d0adb9c1f779/incoming-0.2.5.tar.gz" } ], "0.2.6": [ { "comment_text": "", "digests": { "md5": "eb29d7c925daef241818745e703c6e53", "sha256": "b09d781ecfa97ed05ecf3766073f1e68ba7dee5a5cd061a77198035b76cff488" }, "downloads": -1, "filename": "incoming-0.2.6.tar.gz", "has_sig": false, "md5_digest": "eb29d7c925daef241818745e703c6e53", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10730, "upload_time": "2013-10-19T10:34:15", "url": "https://files.pythonhosted.org/packages/08/1c/c6f498188877cd8d6f58d46f719221aca54fe1a0b7b57a39dd6740581abb/incoming-0.2.6.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "d4c4341484edb260a56f1d3a7a042b74", "sha256": "09058e8681a45f11a079450bb2060ee635bf04817821770ea8792b70c53a9498" }, "downloads": -1, "filename": "incoming-0.3.0.tar.gz", "has_sig": false, "md5_digest": "d4c4341484edb260a56f1d3a7a042b74", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11341, "upload_time": "2015-03-01T22:12:45", "url": "https://files.pythonhosted.org/packages/cb/e2/7615dc7beb7baedf6849c9471085d4e50d3ba64d9dafbade22960a2ed12b/incoming-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "68c8787ece8523ca7f9f6769c66f0547", "sha256": "9bbc3f2b3c7f450c1c283ac2368edfe9b07d54406de8b809416d9e62f9f457b4" }, "downloads": -1, "filename": "incoming-0.3.1.tar.gz", "has_sig": false, "md5_digest": "68c8787ece8523ca7f9f6769c66f0547", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11748, "upload_time": "2015-04-08T06:12:52", "url": "https://files.pythonhosted.org/packages/ee/47/8befa5b32a8d3ac402574f997f310d6747133c21605ffa00eb3229541be8/incoming-0.3.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "68c8787ece8523ca7f9f6769c66f0547", "sha256": "9bbc3f2b3c7f450c1c283ac2368edfe9b07d54406de8b809416d9e62f9f457b4" }, "downloads": -1, "filename": "incoming-0.3.1.tar.gz", "has_sig": false, "md5_digest": "68c8787ece8523ca7f9f6769c66f0547", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11748, "upload_time": "2015-04-08T06:12:52", "url": "https://files.pythonhosted.org/packages/ee/47/8befa5b32a8d3ac402574f997f310d6747133c21605ffa00eb3229541be8/incoming-0.3.1.tar.gz" } ] }