{ "info": { "author": "Ken Martel", "author_email": "ashes.dust@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: POSIX", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities" ], "description": "simpleValidator\n===============\n\n[![PyPI version](https://badge.fury.io/py/simpleValidator.png)](http://badge.fury.io/py/simpleValidator) [![Build Status](https://travis-ci.org/markleent/simpleValidator.png?branch=master)](https://travis-ci.org/markleent/simpleValidator) [![Coverage Status](https://coveralls.io/repos/markleent/simpleValidator/badge.png?branch=master)](https://coveralls.io/r/markleent/simpleValidator?branch=master) [![Downloads](https://pypip.in/d/simpleValidator/badge.png)](https://pypi.python.org/pypi/simpleValidator/) [![License](https://pypip.in/license/simpleValidator/badge.png)](https://pypi.python.org/pypi/simpleValidator/)\n\n\nA small, extensible python 2 (and 3 compatible !) library to deal with web validations !\n\nsimpleValidator (or just Validator actually), comes from the need of having a simple and straightforward validation library in python.\n\nSure some heavy players already exists, like WTForm, but take it as both a challenge and having somefun :), it is also inspired by the simplicity of [Laravel](https://github.com/laravel/laravel)'s own validator class\n\nThe library is standalone, rules are built the python way, in a module and easy to implement, the library is extensible as well !\n\nWhere to use it ? in [Flask](https://github.com/mitsuhiko/flask) for example for people who need very simple validations\n\nN.B. : while i have years of experiences in php, i am mostly a newbie in python, this was a good idea to test on, and my very first OSS project as well :)\n\nInstalling\n----------\n\n 1. pip install simpleValidator\n 2. git clone https://github.com/markleent/simpleValidator.git\n a. cd simpleValidator\n b. run python setup.py\n 3. wget https://github.com/markleent/simpleValidator/archive/master.zip (or download through your browser !)\n a. unzip file\n b. cd simpleValidator-*\n c. run python setup.py\n\n\nUse case:\n---------\n\n```python\nfrom simplevalidator import Validator\n\nmy_items_to_test = {\n 'name': 'myusername',\n 'email': 'myfakeemail@fakedomain.com',\n}\n\nmy_validation_rules = {\n 'name': 'required',\n 'email': 'required|email',\n}\n\nv = Validator()\nv.make(fields = my_items_to_test, rules = my_validation_rules)\n\n### alternatively from the class constructor :\nv = Validator(fields = my_items_to_test, rules = my_validation_rules)\n\n### returns True if the validation failed, False if passed\nif v.fails():\n # do something\nelse: \n # do something else\n\n### returns a list of error messages\nv.errors() \n\n### returns the list of failed validation only (no error message)\nv.failed() \n```\n\nCustom Validation !\n-------------------\n\nsimpleValidator is extensible at runtime ! you can add in your own validation rules and messages !\n\n```python\nfrom simplevalidator import Validator\n\nmy_items_to_test = {\n 'name': 'myusername',\n 'email': 'myfakeemail@fakedomain.com',\n}\n\nmy_validation_rules = {\n 'name': 'required|mycustomrule',\n 'email': 'required|email',\n}\n\nmy_validation_messages = {\n 'mycustomrule': '{0} is not equal to 1 !'\n}\n\ndef mycustomrule(value):\n return value == 1\n\nv = Validator()\nv.extend({'mycustomrule': mycustomrule})\n\nv.make(fields = my_items_to_test, rules = my_validation_rules, messages = my_validation_messages)\n\nprint(v.fails())\n### outputs True\n\nprint(v.errors())\n### outputs ['name is not equal to 1 !']\n\n```\n\ni18n\n----\n\nsimpleValidator supports i18n, through gettext, for now a list of 3 languages are available : English (en), French (fr), Japanese (ja)\n\n```python\nfrom simplevalidator import Validator, i18n\n\ni18n.switch_language('fr')\n\nfields = {'username': ''}\nrules = {'username': 'required'}\n\nv = Validator(fields = fields, rules = rules)\n\nprint(v.errors())\n## > ['username est requis']\n\n\n\ni18n.switch_language('ja')\n\nv = Validator(fields = fields, rules = rules)\n\nprint(v.errors())\n## > ['username\u306f\u5fc5\u305a\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002']\n```\n\n\nRules List\n==========\n\n * required, field to validate must contain a value\n * email, field must be a valid email\n * alpha, field must contain alphabetical characters only\n * alpha_num, field must contain alphabetical characters and/or numbers\n * alpha_dash, field must contain alphabetical characters, numbers, dashes and underscores\n * numeric, field must contain a numerical value\n * integer, field must be an integer only\n * posinteger, field must be a positive integer only\n * min, depending on field:\n - string, size must be at least of min value (ex min = 5, \"mystring\" is valid)\n - numerical, value must be at least higher or equal to min value (ex min = 22, 39 is valid)\n * max, depending on field:\n - string, size must at most be of max value (ex max = 10, \"hello world\" is NOT valid)\n - numerical, value must be lower or equal than max value (ext max = 10, 12 is NOT valid)\n * between, depending on value:\n - string, size must be between the boundary values (ex between = (5,10), \"hello !\" is valid)\n - numerical, value must be between the 2 values \n * ip4, field must be a valid ipv4 address\n * ip6, field must be a valid ipv6 address\n * date, field must be a valid date, corresponding to a specific template\n * url, field must be a valid url (https, and port are allowed)\n\n\nTo Do\n-----\n\n - Add more validation rules with time...\n - Add support for file validation (mime type, file size etc...)\n - Add support for json validation (through templates) \n\n\n\n\nIs it UnitTested ?\n------------------\n\nAll tests files where merged for conveniance in one file that can be either run :\n\n 1. python setup.py test\n 2. python tests.py\n\n\n\n\nLicense\n-------\n\nReleased under a ([MIT](LICENSE)) license.", "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/markleent/simpleValidator.git", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "simpleValidator", "package_url": "https://pypi.org/project/simpleValidator/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/simpleValidator/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/markleent/simpleValidator.git" }, "release_url": "https://pypi.org/project/simpleValidator/0.0.6.0/", "requires_dist": null, "requires_python": null, "summary": "A small, extensible python library to deal with web validations !", "version": "0.0.6.0" }, "last_serial": 996018, "releases": { "0.0.5": [ { "comment_text": "", "digests": { "md5": "e7268b91976d90082741a7c37d6fa988", "sha256": "08473da3f988541d320931afcc9285e8481ebfe182bdcfdc29d6c9c3fefa4e46" }, "downloads": -1, "filename": "simpleValidator-0.0.5.tar.gz", "has_sig": false, "md5_digest": "e7268b91976d90082741a7c37d6fa988", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15326, "upload_time": "2014-01-28T18:42:09", "url": "https://files.pythonhosted.org/packages/d1/3d/fbc3ebb1d12634a952220bbd56e0a08eb117f7d2b6958920f773923b3b84/simpleValidator-0.0.5.tar.gz" } ], "0.0.5.3": [ { "comment_text": "", "digests": { "md5": "9f5367a4ebf49c351be4260d00715042", "sha256": "f7586ad712b89f69e2c93c5338e59cc5bff289e1351eea12b16dd52f37488451" }, "downloads": -1, "filename": "simpleValidator-0.0.5.3.tar.gz", "has_sig": false, "md5_digest": "9f5367a4ebf49c351be4260d00715042", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19051, "upload_time": "2014-01-28T20:19:14", "url": "https://files.pythonhosted.org/packages/a5/92/8e9324bb606aebc0ac16879c8d6b8537512b191a19fdd761790f347394f8/simpleValidator-0.0.5.3.tar.gz" } ], "0.0.5.4": [ { "comment_text": "", "digests": { "md5": "5d8ae5c9162b3c8542fa998cd5f76e57", "sha256": "a457430bdc6be2e3ce32439465c2d8961448d39d18fe591108f7e1ee9be49d03" }, "downloads": -1, "filename": "simpleValidator-0.0.5.4.tar.gz", "has_sig": false, "md5_digest": "5d8ae5c9162b3c8542fa998cd5f76e57", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19830, "upload_time": "2014-01-29T18:48:44", "url": "https://files.pythonhosted.org/packages/4b/87/30f9f15ab6c5ecf50a483ca7d4c5981cf2c66f581f5619601f4355f28192/simpleValidator-0.0.5.4.tar.gz" } ], "0.0.5.6": [ { "comment_text": "", "digests": { "md5": "e781014d72ee18fc89ff85129db9a565", "sha256": "b158052d0d8d81b7bb982b22f3db67370ea9d3251a6b33f7d89e642f62a18c15" }, "downloads": -1, "filename": "simpleValidator-0.0.5.6.tar.gz", "has_sig": false, "md5_digest": "e781014d72ee18fc89ff85129db9a565", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19806, "upload_time": "2014-01-29T21:54:47", "url": "https://files.pythonhosted.org/packages/db/60/7d2beb748ebdb46e6554d25831084ad748c29f190c51fe7d9e0427c39a98/simpleValidator-0.0.5.6.tar.gz" } ], "0.0.5.8": [ { "comment_text": "", "digests": { "md5": "c287ffbaa776c4ef4365899c5dadf4fb", "sha256": "431c928032179e86dd0047f5565d8260b6e9701e451e1809536ba1bfcc8e5d31" }, "downloads": -1, "filename": "simpleValidator-0.0.5.8.tar.gz", "has_sig": false, "md5_digest": "c287ffbaa776c4ef4365899c5dadf4fb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20397, "upload_time": "2014-02-06T08:37:17", "url": "https://files.pythonhosted.org/packages/a8/e2/045ecc674ad79467fb9dce3e4820a7ae6a49055aa1c4742d9ac079f06356/simpleValidator-0.0.5.8.tar.gz" } ], "0.0.5.9": [ { "comment_text": "", "digests": { "md5": "cdbeac705b2e79926b1723f7fdc3c023", "sha256": "1de7f0ccf3c7eb384fd2450e9e0fafdea5f03ee1c584c80aea337f26f400f127" }, "downloads": -1, "filename": "simpleValidator-0.0.5.9.tar.gz", "has_sig": false, "md5_digest": "cdbeac705b2e79926b1723f7fdc3c023", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20538, "upload_time": "2014-02-10T09:24:34", "url": "https://files.pythonhosted.org/packages/b2/6c/209e3edd52ab7c0f798ef29bc4ee2978fc9f210e245fc1129f197277e53e/simpleValidator-0.0.5.9.tar.gz" } ], "0.0.6.0": [ { "comment_text": "", "digests": { "md5": "75636ddf267b069a3fb3d106ba94cf1b", "sha256": "d4d7da8716c6535400a8bde91a154547ddcdd91033ef11b029f35c9250c9d78b" }, "downloads": -1, "filename": "simpleValidator-0.0.6.0.tar.gz", "has_sig": false, "md5_digest": "75636ddf267b069a3fb3d106ba94cf1b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20616, "upload_time": "2014-02-10T10:04:36", "url": "https://files.pythonhosted.org/packages/64/ce/a33e4bf463015123c14ded8f2200777231087d35b6cf802a6e74427a63c1/simpleValidator-0.0.6.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "75636ddf267b069a3fb3d106ba94cf1b", "sha256": "d4d7da8716c6535400a8bde91a154547ddcdd91033ef11b029f35c9250c9d78b" }, "downloads": -1, "filename": "simpleValidator-0.0.6.0.tar.gz", "has_sig": false, "md5_digest": "75636ddf267b069a3fb3d106ba94cf1b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20616, "upload_time": "2014-02-10T10:04:36", "url": "https://files.pythonhosted.org/packages/64/ce/a33e4bf463015123c14ded8f2200777231087d35b6cf802a6e74427a63c1/simpleValidator-0.0.6.0.tar.gz" } ] }