{ "info": { "author": "Walid Mashal", "author_email": "walidmashal4@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "### LaraValidation\n[![Release](https://img.shields.io/github/release/kristopherchun/laravalidation.svg)](https://github.com/kristopherchun/laravalidation/releases/latest)\n[![Travis CI Build Status](https://travis-ci.org/kristopherchun/laravalidation.svg?branch=master)](https://travis-ci.org/kristopherchun/laravalidation)\n[![Coverage Report](https://codecov.io/gh/kristopherchun/laravalidation/branch/master/graph/badge.svg)](https://codecov.io/gh/kristopherchun/laravalidation)\n\nOriginal forked repo: https://github.com/walid-mashal/Laravel-Validation\n\n**LaraValidation** is a python module containing logic for implementing Laravel style Data Validation using python language. This code can be used with html forms to validate their input fields and can also be used with any kind of other data as long as the data is in the form of a python dictionary.\n\nFor Example we can have some data in the form of a python dictionary as the following:\n\n data = { \n 'name':'2222222', \n 'phone':'2', \n 'birthday':'1991/03/04', \n 'email':'info@example.com', \n 'host':'172.30.30.231', \n 'website':'https://www.example.com', \n 'nationality':'afghan',\n 'active':'1', \n }\n\nthat needs to be validated.\n\nSo we can write Rules to validate the data in the following way\n\n rules = { \n 'name':'required|size:20', \n 'phone':'phone', \n 'birthday':'date|date_format:%Y/%m/%d', \n 'email':'required|email',\n 'host':'ip', \n 'website':'website', \n 'nationality':'in:afghan,pakistani,irani',\n 'active':'boolean'\n } \n\nDescription:\n\nThe **name** field is a required field and only allows a maximum value of 20 characters.\n\nThe **Phone** field is a telephone number field and a valid phone number should be entered for this field.\n\nThe **birthday** field is a date field and the value entered should be a valid date, the date_format allows you to specify a date format that the field should be filled with.\n\nThe **email** is also required and a valid email should be entered into that field \n\n**Host** must be a valid ip address e.g. 196.3.3.8\n\n**Website** must be a valid website address e.g. http://www.google.com \n\n**Nationality** can be one of the three provided strings: afghan,pakistani,irani \n\n**Active** must be one of the following: 1,0,\"1\",\"0\",\"false\",\"true\",False,True\n\n\nNow we can write the following code to validate the **data**:\n\n from validation import Validation\n\n validator = Validation()\n errors = validator.validate(data,rules)\n\nNow the **errors** contain a list of error messages that is the result of the validation.\n\n**validate()** also takes an optional **custom_messages** argument which will set user messages to be used for validation, or instead of passing the **custom_messages** argument you can actually set the messages of your own choice using the **cutom_error_messages.json** file.\n\n\nWe can call the **is_valid()** method to validate the data and will return either **True** or **False** \n\n from validation import Validation\n\n validator = Validation()\n isvalid = validator.is_valid(data,rules)\n\t\n errors = validator.errors\n \nAfter **validate()** or **is_valid()** there will be an instance variable with the name **errors** set on the object that holds the list of validation error messages.\n\n### Validation Rules\n\nThe following is a list of the validation rules available\n\n#### after\n\nThe field under validation must be a value after a given date.\n\n#### alpha\n\nThe field under validation must be entirely alphabetic characters.\n\n#### alpha_num\n\nThe field under validation must be entirely alpha-numeric characters.\n\n#### before:date\n\nThe field under validation must be a value preceding the given date.\n\n#### between:min,max\n\nThe field under validation must have a size between the given **min** and **max**. Strings and numerics are evaluated in the same fashion as the **size** rule.\n\n#### boolean\n\nThe field under validation must be able to be cast as a **boolean**. Accepted input values are true, false, 1, 0, \"1\" and \"0\".\n\n#### confirmed\n\nThe field under validation must have a matching field of foo_confirmation. For example, if the field under validation is password, a matching password_confirmation field must be present in the input.\n\n#### date\n\nThe field under validation must be a valid date, the default value for the format is **%m/%d/%Y** if no **date_format** rule is applied.\n\n#### date_format:format\n\nThe field under validation must match the format defined in the **format**, the default format is **%m/%d/%Y**. This rule should be preceeded by the **date** rule.\n\n#### different:field\n\nThe given field must be different than the field under validation.\n\n#### digits:value\n\nThe field under validation must be numeric and must have an exact length of **value**.\n\n#### email\n\nThe field under validation must be formatted as an e-mail address.\n\n#### integer\n\nThe field under validation must have an integer value.\n\n#### ip\n\nThe field under validation must be formatted as an IP address.\n\n#### max:value\n\nThe field under validation must be less than or equal to a maximum value. Strings, numerics, and files are evaluated in the same fashion as the size rule.\n\n#### min:value\n\nThe field under validation must have a minimum value. Strings, numerics, and files are evaluated in the same fashion as the size rule.\n\n#### not_in:foo,bar,...\n\nThe field under validation must not be included in the given list of values.\n\n#### present\n\nThe field under validation must be present in the input data but can be empty.\n\n#### regex:pattern\n\nThe field under validation must match the given regular expression.\n\n#### required\n\nThe field under validation must be present in the input data.\n\n#### same:field\n\nThe given field must match the field under validation.\n\n#### size:value\n\nThe field under validation must have a size matching the given **value**. For string data, value corresponds to the number of characters. For numeric data, **value** corresponds to a given integer value.\n\n#### website\n\nThe field under validation must have a valid website url as value. for example: https://www.example.com or www.example.com", "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/kristopherchun/laravalidation.git", "keywords": "validation,python,laravel", "license": "", "maintainer": "", "maintainer_email": "", "name": "laravalidation", "package_url": "https://pypi.org/project/laravalidation/", "platform": "", "project_url": "https://pypi.org/project/laravalidation/", "project_urls": { "Homepage": "https://github.com/kristopherchun/laravalidation.git" }, "release_url": "https://pypi.org/project/laravalidation/0.4.1/", "requires_dist": null, "requires_python": "", "summary": "Laravel like data validation library for python language", "version": "0.4.1" }, "last_serial": 5239368, "releases": { "0.3": [ { "comment_text": "", "digests": { "md5": "a459844d75f2bf86cba277200ee7b675", "sha256": "ab75085d2d84ee57cc758100a7b166b89b3a9003154133d8257c0a469efa6bce" }, "downloads": -1, "filename": "laravalidation-0.3.tar.gz", "has_sig": false, "md5_digest": "a459844d75f2bf86cba277200ee7b675", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9258, "upload_time": "2019-05-07T00:55:37", "url": "https://files.pythonhosted.org/packages/26/25/365f349bc75e731098278c447dbf0f21807184d7ebb518c5a50e1cd9523d/laravalidation-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "0229383ebf61e400464ecc5912bdc6df", "sha256": "60f03dee889d4b1b5734e1b8aec46da9e48e457e576ca259cd6d071a5a4feef5" }, "downloads": -1, "filename": "laravalidation-0.4.tar.gz", "has_sig": false, "md5_digest": "0229383ebf61e400464ecc5912bdc6df", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9253, "upload_time": "2019-05-07T17:06:23", "url": "https://files.pythonhosted.org/packages/c5/cd/4ed71a317fe69bdaec438b6d2c8a17f2d35989d8159134df45af0a023122/laravalidation-0.4.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "63d05e15f511f48122c63d4cb61cdc05", "sha256": "fe7f2a9f09e1002816b09a6989c2eb0562198e3cfe34395c2498b716b6257de8" }, "downloads": -1, "filename": "laravalidation-0.4.1.tar.gz", "has_sig": false, "md5_digest": "63d05e15f511f48122c63d4cb61cdc05", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9243, "upload_time": "2019-05-07T18:34:17", "url": "https://files.pythonhosted.org/packages/9d/4e/15afe3e2c2e2ae2808b6bee759efbf345b349037ca71825467bf342cf86a/laravalidation-0.4.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "63d05e15f511f48122c63d4cb61cdc05", "sha256": "fe7f2a9f09e1002816b09a6989c2eb0562198e3cfe34395c2498b716b6257de8" }, "downloads": -1, "filename": "laravalidation-0.4.1.tar.gz", "has_sig": false, "md5_digest": "63d05e15f511f48122c63d4cb61cdc05", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9243, "upload_time": "2019-05-07T18:34:17", "url": "https://files.pythonhosted.org/packages/9d/4e/15afe3e2c2e2ae2808b6bee759efbf345b349037ca71825467bf342cf86a/laravalidation-0.4.1.tar.gz" } ] }