{ "info": { "author": "Kevin Novak", "author_email": "kevin@uber.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Testing" ], "description": "Minos: A Lightweight Validation Framework\n=========================================\n`Minos` is a library that you can use in your code to create a simple validation\nframework. Its aim is to provide a lightweight interface of functions that make it\nsimple to quickly build and manipulate models.\n\n.. toctree::\n :maxdepth: 2\n\nInstallation\n============\n\nTo install Minos locally:\n\n::\n\n $ python setup.py develop\n\n\nMinos will soon be on PyPi.\n\n.. _Quickstart:\n\nQuickstart\n==========\n\nThere are a few patterns Minos was designed to support; class validation with validators declared as\npart of the class definition, class validation where the validators are declared seperately, and as\ntotally independant object validators. See below for a few examples of each pattern.\n\nClass Validators in Class Definition\n------------------------------------\n\nTo declare validators inside of a class, the class needs to inherit from the Minos Mixin, and the\nvalidation arguments are passed to each validator on instantiation.\n\nFor example, given a class definition like so:\n\n.. sourcecode:: python\n\n import minos\n import pytz\n\n from datetime import datetime\n from minos.validators import DatetimeValidator, NumericalityValidator, PresenceValidator\n\n\n class Toaster(minos.Mixin):\n\n #Attributes\n\n created_at = None\n num_slots = None\n\n #Validators\n\n validators = [\n DatetimeValidator('created_at'),\n PresenceValidator('num_slots'), # every toaster needs to have its number of slots specified\n #Toasters can only have an integer number of slots between 2-8\n NumericalityValidator(\n 'num_slots',\n integer_only=True,\n greater_than_or_equal_to=2,\n less_than_or_equal_to=8\n )\n ]\n\n\n def __init__(self, bread):\n self.bread = bread\n self.created_at = datetime.now(pytz.utc)\n\n #...class definition continues...\n\n\nWhen using the ToasterClass in code, you can do stuff like this:\n\n.. sourcecode:: python\n\n def toast_bread(bread):\n toaster = Toaster(num_slots=4)\n try:\n toaster.validate() # Validates that toaster's attributes are valid\n except minos.errors.FormValidationError:\n raise ToastError(\"can't toast bread, toasters busted.\")\n\n toasted_bread = toaster.toast(bread)\n\n return toasted_bread\n\nClass Validators Outside Class Definition\n-----------------------------------------\n\nSimilarly, You can also create a validator that validates a single attribute of a python object,\nand pass objects to be validated to it using the Validator's *.validate_wrapper()* call.\n\n\n.. sourcecode:: python\n\n import minos\n from minos.validators import NumericalityValidator\n\n #Create a validator that for a toaster's slots ahead of time\n slot_validator = NumericalityValidator(\n 'num_slots',\n integer_only=True,\n greater_than_or_equal_to=2,\n less_than_or_equal_to=8\n )\n\n #Given a list of toasters, validate them all\n for toaster in [dorm_toaster, kitchen_toaster, fancy_toaster]:\n try:\n #Check this toaster using the parameters specified earlier\n slot_validator.validate_wrapper(toaster)\n except minos.errors.FormValidationError:\n print \"{} doesn't have the right number of slots.\".format(toaster.name)\n\nSingle\\-Use Validation\n----------------------\n\nYou can also create validators without configuration, and specify the configuration inline using the *.validate()* call:\n\n\n.. sourcecode:: python\n\n from minos.validators import NumericalityValidator\n from minos.errors import ValidationError\n\n #Make a validator that checks numeric qualities of objects\n accountant = NumericalityValidator()\n\n\n #Check a bunch of stuff\n\n try:\n accountant.validate(bank_account, greater_than=0)\n except ValidationError:\n print \"You're broke!\"\n\n try:\n accountant.validate(tax_payment, greater_than=0, less_than=5000.00)\n except ValidationError:\n print \"You're tax payment doesn't seem right...\"\n\n try:\n accountant.validate(num_deductions, integer_only=True)\n except ValidationError:\n print \"Your number of deductions doesn't make sense.\"", "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/uber/minos", "keywords": "tests,validation", "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "Minos", "package_url": "https://pypi.org/project/Minos/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/Minos/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/uber/minos" }, "release_url": "https://pypi.org/project/Minos/0.1.2/", "requires_dist": null, "requires_python": null, "summary": "Minos is a library to do flexible validation of Python objects", "version": "0.1.2" }, "last_serial": 883542, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "c8d2b16d62f945119064d3270f803779", "sha256": "c6d75b59900dc72c361a109ba20ec065fe2766574d0a59d0574721689cb778c7" }, "downloads": -1, "filename": "Minos-0.1.tar.gz", "has_sig": false, "md5_digest": "c8d2b16d62f945119064d3270f803779", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5642, "upload_time": "2013-09-27T20:19:56", "url": "https://files.pythonhosted.org/packages/f7/82/b4613fd37e5be39b46b2ceb4aab0c6797d554b38e28028ec0b5a8ab3a846/Minos-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "24dc2ec1966921e100fd0de9f7ef7752", "sha256": "09b0306e1e6e6f960f39ec24f324f29a1bb5228ac88374f8b426b8b36bda1f8b" }, "downloads": -1, "filename": "Minos-0.1.1.tar.gz", "has_sig": false, "md5_digest": "24dc2ec1966921e100fd0de9f7ef7752", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5591, "upload_time": "2013-09-27T20:29:35", "url": "https://files.pythonhosted.org/packages/b2/bc/c761dd76898a419a9cd7cf2fa7c5d17d9f3bbab699cac5b1371ee017f859/Minos-0.1.1.tar.gz" } ], "0.1.1a": [ { "comment_text": "", "digests": { "md5": "74b7f8c43d3493d332057089571aaf18", "sha256": "3a2ae24ed3245a574ba9494ff2c77302748f8d0e2c71db80ad0b2b2bd781e22c" }, "downloads": -1, "filename": "Minos-0.1.1a.tar.gz", "has_sig": false, "md5_digest": "74b7f8c43d3493d332057089571aaf18", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13291, "upload_time": "2013-10-04T19:03:28", "url": "https://files.pythonhosted.org/packages/8f/54/8ad76c538d104f6741437ff522685a217d7b108ed52e1d55821831b8e8d3/Minos-0.1.1a.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "b383fb72d0747e7387f6585e755291df", "sha256": "274d0c677ab533e9ad8b3c69f266ea320b858eacd1817421799066ca135e66c0" }, "downloads": -1, "filename": "Minos-0.1.2.tar.gz", "has_sig": false, "md5_digest": "b383fb72d0747e7387f6585e755291df", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13287, "upload_time": "2013-10-07T21:40:33", "url": "https://files.pythonhosted.org/packages/a8/38/bb3d093e1b7543651d4a7255e5110ae362007e2399a3c5b0be1aabd6646a/Minos-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b383fb72d0747e7387f6585e755291df", "sha256": "274d0c677ab533e9ad8b3c69f266ea320b858eacd1817421799066ca135e66c0" }, "downloads": -1, "filename": "Minos-0.1.2.tar.gz", "has_sig": false, "md5_digest": "b383fb72d0747e7387f6585e755291df", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13287, "upload_time": "2013-10-07T21:40:33", "url": "https://files.pythonhosted.org/packages/a8/38/bb3d093e1b7543651d4a7255e5110ae362007e2399a3c5b0be1aabd6646a/Minos-0.1.2.tar.gz" } ] }