{ "info": { "author": "Amirreza salimi", "author_email": "amirrezasalimi0@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# vlight\n\n\nsimple package for validation data\n\n## Getting Started\n\n\n### Installing\n\nif you have old version do this:\n\n`pip uninstall vlight`\n\nand to install latest version :\n`pip install vlight`\n\n\n#### use vlight\n\n\n```python\nfrom vlight import v\n```\n\n\n### examples\n\nvalidate a simple login form with email :\n\n```python\nfrom vlight import valid # also you can use \"v\" helper method\n```\n\n\n#### vlight in django\n\n`create validation rules and set data`\n```python\nfrom vlight import v\nvalid = v({\n \"email\": \"req|email\",\n \"password\": \"req|min:8|max:255\"\n}, data={\n \"email\":\"test@gmail.com\",\n \"password\": \"123\" # this field have minimum character error\n})\n#check data is valid\n\nif valid.isOk():\n # submit your form\n pass\n\nerror=valid.errors()\n#check have error\nif valid.fails():\n msgs=error.all()\n\n#check a field have error\n\nif error.has(\"email\"):\n #this block run when your email field have error\n pass\n\n#get field errors messages\nprint(error.get(\"email\"))\n# you can set returned error length\nprint(error.get(\"email\",2)) \n\n\n#customize error messages\n\n#to customize all fields default messages:\nvalid = v({\n \"email\": \"required|email\",\n \"password\": \"required|min:8|max:255\"\n}, data={\n \"email\":\"test@gmail.com\",\n \"password\": \"123\"\n},messages={\n \"required\":\"{field} required \",\n \"email\": \"email field with value [{value}] not valid\",\n }\n)\n\n#or you can customize only a field messages\nvalid = v({\n \"email\": \"required|email\"\n \"|required.msg:enter your email\"\n \"|email.msg:email is not valid\",\n\n \"password\": \"required|min:8|max:255\"\n \"|str.min:your password is easy\"\n \"|str.max:your selected password so hard\"\n}, data={\n \"email\":\"test@gmail.com\",\n \"password\": \"123\"\n})\n```\n\n\n\n\n##### an example in django\n\n`views.py`\n```\nfrom django.shortcuts import render\nfrom vlight import v\n\ndef index(request, **kwargs):\n msgs = []\n if request.method == \"POST\":\n\n valid = v({\n \"email\": \"required|email\",\n \"password\": \"required|min:8|max:255\"\n }, data=request.POST)\n\n if valid.fails():\n msgs = valid.errors().all()\n else:\n msgs.append(\"your form submitted!\")\n\n return render(request, \"index.html\", {\"login_errors\": msgs}) \n```\n`index.html` jinja2\n```\n
\n```\n\n#### supported rules\n\n`required` check data has field and data is not empty\n```\n\"required\"\n```\n`email` pattern : `^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$`\n```\n\"email\"\n```\n\n`ip` pattern : `^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$`\n```\n\"ip\"\n```\n\n`url` pattern : `^http(s?):\\/\\/(www\\.)?(((\\w+(([\\.\\-]{1}([a-z]{2,})+)+)(\\/[a-zA-Z0-9\\_\\=\\?\\&\\.\\#\\-\\W]*)*$)|(\\w+((\\.([a-z]{2,})+)+)(\\:[0-9]{1,5}(\\/[a-zA-Z0-9\\_\\=\\?\\&\\.\\#\\-\\W]*)*$)))|(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(([0-9]|([1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]+)+)(\\/[a-zA-Z0-9\\_\\=\\?\\&\\.\\#\\-\\W]*)*)((\\:[0-9]{1,5}(\\/[a-zA-Z0-9\\_\\=\\?\\&\\.\\#\\-\\W]*)*$)*))$`\n```\n\"url\"\n```\n\n`not_in` `in` check value in items\n```\n\"in:small,larg\"\n```\n\n\n\n`regex`\n`not_regex` coming soon\n\n\n`ext` check path extension \n```\n\"ext:jpg,png,jpeg\"\n```\n\n`int` integer validation\n```\n\"int\"\n```\n`max` set maximum character of string\n```\n\"max:255\"\n```\nand you can change the rule for int value to check max integer value\n```\n\"int|max:255\"\n```\n\n\n\n\n\n##### [ more validation rules will added coming soon ]\n\n\n\n\n#### develop your rule\n\n`docs coming soon`\n\n#### latest version changes\n\n`0.1`\n- fix bugs\n\n# contact \n\n- telegram: https://t.me/Amir_s365\n- gmail: amirrezasalimi0@gmail.com\n\n\n# License\n\n\nThis project is licensed under the MIT License\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/amirrezasalimi/vlight", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "vlight", "package_url": "https://pypi.org/project/vlight/", "platform": "", "project_url": "https://pypi.org/project/vlight/", "project_urls": { "Homepage": "https://github.com/amirrezasalimi/vlight" }, "release_url": "https://pypi.org/project/vlight/1.2.1/", "requires_dist": null, "requires_python": "", "summary": "a simple package for validation data", "version": "1.2.1" }, "last_serial": 4303237, "releases": { "1.2.0": [ { "comment_text": "", "digests": { "md5": "b7b183a8f00283e834399ef67e663dd2", "sha256": "af2dca6a3fefb3b860d4c8d5eaebe9795e619f1274beb17059db3c5867e9c84e" }, "downloads": -1, "filename": "vlight-1.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "b7b183a8f00283e834399ef67e663dd2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4926, "upload_time": "2018-09-23T23:11:49", "url": "https://files.pythonhosted.org/packages/85/0a/0c65ad315c927778eda3a86a2a2fb7756afeb852cd6a939de11a6c76cd5f/vlight-1.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e9f6e82b5f6aa257197f71d1519b329b", "sha256": "3a44891a1eeded3faf2c3d99a7a821b4767f79c644e6a7df0f4b2828bd5aabb5" }, "downloads": -1, "filename": "vlight-1.2.0.tar.gz", "has_sig": false, "md5_digest": "e9f6e82b5f6aa257197f71d1519b329b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4770, "upload_time": "2018-09-23T23:11:50", "url": "https://files.pythonhosted.org/packages/89/a1/62f5632eb7798f35212ef1f335c00fce3d41579686a68e31ccccb8233863/vlight-1.2.0.tar.gz" } ], "1.2.1": [ { "comment_text": "", "digests": { "md5": "4c6bc3e0ffa27c7e4585af658c4abae2", "sha256": "0f6116dcf8e90ecb49bfec1049c125cab6c1fbaa3fe2e61bf707d8abb3774fc8" }, "downloads": -1, "filename": "vlight-1.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "4c6bc3e0ffa27c7e4585af658c4abae2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4930, "upload_time": "2018-09-23T23:30:52", "url": "https://files.pythonhosted.org/packages/6b/12/e151bc64826b7d969fe7c08fb405222f28a9ef42f79f28812205da9253af/vlight-1.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2d7083bc0ce194232d0f779d3cb5dbc1", "sha256": "1bc2ccf5f4ecc7fd5a43fa09e2314c46145b9446f0b8904a378548b86c11bf04" }, "downloads": -1, "filename": "vlight-1.2.1.tar.gz", "has_sig": false, "md5_digest": "2d7083bc0ce194232d0f779d3cb5dbc1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4784, "upload_time": "2018-09-23T23:30:55", "url": "https://files.pythonhosted.org/packages/c9/f7/569c9db584a9604bfa08a1eef6535fb22bf620a5ab802b3fe7d8579fd8d9/vlight-1.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4c6bc3e0ffa27c7e4585af658c4abae2", "sha256": "0f6116dcf8e90ecb49bfec1049c125cab6c1fbaa3fe2e61bf707d8abb3774fc8" }, "downloads": -1, "filename": "vlight-1.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "4c6bc3e0ffa27c7e4585af658c4abae2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4930, "upload_time": "2018-09-23T23:30:52", "url": "https://files.pythonhosted.org/packages/6b/12/e151bc64826b7d969fe7c08fb405222f28a9ef42f79f28812205da9253af/vlight-1.2.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2d7083bc0ce194232d0f779d3cb5dbc1", "sha256": "1bc2ccf5f4ecc7fd5a43fa09e2314c46145b9446f0b8904a378548b86c11bf04" }, "downloads": -1, "filename": "vlight-1.2.1.tar.gz", "has_sig": false, "md5_digest": "2d7083bc0ce194232d0f779d3cb5dbc1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4784, "upload_time": "2018-09-23T23:30:55", "url": "https://files.pythonhosted.org/packages/c9/f7/569c9db584a9604bfa08a1eef6535fb22bf620a5ab802b3fe7d8579fd8d9/vlight-1.2.1.tar.gz" } ] }