{ "info": { "author": "Marcelo Fonseca Tambalo", "author_email": "marcelo.tambalo@nectosystems.com.br", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation", "Topic :: Software Development :: Libraries" ], "description": "xpath_validator \n===============\n\n.. image:: https://travis-ci.org/znc-sistemas/xpath_validator.svg?branch=master\n :target: https://travis-ci.org/znc-sistemas/xpath_validator\n\n.. image:: https://coveralls.io/repos/github/znc-sistemas/xpath_validator/badge.svg?branch=master\n :target: https://coveralls.io/github/znc-sistemas/xpath_validator?branch=master\n\n.. image:: https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square\n :target: https://raw.githubusercontent.com/znc-sistemas/xpath_validator/master/LICENSE.txt\n :alt: Package license\n\nValidate boolean expressions with XPath syntax\n\nvalidate('expression', 'value', 'context', 'returns_bool')\n\n- expression: string with the expression text\n- value: value that will be validated (it is replaced by the occurrences of '.' in the expression)\n- context: dictionary that will make substitutions in $ {name}\n- returns_bool: if true, automatically returns a boolean\n\nExamples\n--------\n\n.. code-block:: python\n \n >>> validate('. >= 1 and . <= 100', 10)\n True\n >>> validate('. >= 1 and . <= 100', 101)\n False\n >>> validate('not(. >= 1 and . <= 100)', -10)\n True\n >>> validate('ceiling(.) = 5', 4.3)\n True\n >>> validate('floor(.) = 4', 4.7)\n True\n >>> validate('floor(.) = 4', 4.2)\n True\n >>> validate('int(.) = 4', 4.7)\n True\n >>> validate('number(.) = 3.2', 3.2)\n True\n >>> validate('choose(true(), 1, 2) = 1', None)\n True\n >>> validate('choose(false(), 1, 2) = 2', None)\n True\n >>> validate('contains(\"abc\", .)', \"b\")\n True\n >>> validate('contains(\"abc\", .)', \"e\")\n False\n >>> validate('number(string(.)) = 6', 6)\n True\n >>> validate('string-length(.) = 15', \"632587415222360\")\n True\n >>> validate('string_length(.) = 11', \"40258997853\")\n True\n >>> validate('string_length(.) = 7', \"abacate\")\n True\n >>> validate('5 < .', 10)\n True\n >>> validate('5 > .', 10)\n False\n >>> validate('5 != .', 5)\n False\n >>> validate('5 != .', 10)\n True\n >>> validate('5 + 5 = .', 10)\n True\n >>> validate('5 - 51 = .', -46)\n True\n >>> validate('true() or false()', None)\n True\n >>> validate('false() or false()', None)\n False\n >>> validate('(. div 5) = 2', 10)\n True\n >>> validate('(. * 5) = 50', 10)\n True\n >>> validate('(. div 5) < .', 10)\n True\n >>> validate('(. * 5) > .', 10)\n True\n >>> validate('(. mod 2) = 0', 10)\n True\n >>> validate('(. mod 2) = 1', 11)\n True\n >>> validate('(. mod 2) = 1', 10)\n False\n >>> validate('(. mod 2) = 0', 11)\n False\n >>> validate(\"int(format-date-time(., '%H')) = 19\", '2019-05-14T19:13:35.450686Z')\n True\n >>> validate(\"int(format-date-time(., '%m')) = 5\", '2019-05-14T19:13:35.450686Z')\n True\n >>> validate(\"int(format-date-time(., '%M')) = 13\", '2019-05-14T19:13:35.450686Z')\n True\n >>> validate(\"int(format-date-time(., '%Y')) = 2019\", '2019-05-14T19:13:35.450686Z')\n True\n >>> validate(\"int(format-date-time(., '%d')) = 14\", '2019-05-14T19:13:35.450686Z')\n True\n >>> validate(\"format-date-time(., '%d/%m/%Y') = '14/05/2019'\", '2019-05-14T19:13:35.450686Z')\n True\n >>> validate('. >= ${min} and . <= ${max}', 10, {\"max\": 100, \"min\": 10})\n True\n >>> validate('. >= ${min} and . <= ${max}', 10, {\"max\": 100, \"min\": 20})\n False\n >>> validate('${min} = \"\" and ${max} = \"\"', None, {\"max\": 100, \"min\": 20})\n False\n >>> validate(\"substring-after('aa&bb', ${sep}) = 'bb'\", \"&\", {'sep': '&'})\n True\n >>> validate(\"substring-before('aa&bb', ${sep}) = 'aa'\", \"&\", {'sep': '&'})\n True\n >>> validate(\"normalize-space(' abacate ') = 'abacate'\", None)\n True\n >>> validate(\"starts-with('abacate', 'ab')\", None)\n True\n >>> validate(\"starts-with('abacate', 'ac')\", None)\n False\n >>> validate(\"uuid()\", None, returns_bool=False)\n '2327c8bc-ac46-4968-a73c-5f21f9e9b1ce'\n >>> validate('(. div -5)', 10, returns_bool=False)\n -2.0\n >>> validate(\"selected('peixe abacate', .)\", 'peixe')\n True\n >>> validate(\"selected('peixe abacate', 'peixe')\", None)\n True", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/znc-sistemas/xpath_validator/", "keywords": "XPath", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "xpath-validator", "package_url": "https://pypi.org/project/xpath-validator/", "platform": "", "project_url": "https://pypi.org/project/xpath-validator/", "project_urls": { "Homepage": "https://github.com/znc-sistemas/xpath_validator/" }, "release_url": "https://pypi.org/project/xpath-validator/1.5.1/", "requires_dist": null, "requires_python": "", "summary": "validate boolean expressions with XPath syntax", "version": "1.5.1" }, "last_serial": 5756445, "releases": { "1.5.0": [ { "comment_text": "", "digests": { "md5": "a575c14cd65f59b9bc6ac7bbadc81779", "sha256": "8ea9e2992cd37a6c3aa9b61e87573c58db8d1eb15fdd55749fa061984d33a129" }, "downloads": -1, "filename": "xpath_validator-1.5.0.tar.gz", "has_sig": false, "md5_digest": "a575c14cd65f59b9bc6ac7bbadc81779", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9287, "upload_time": "2019-08-29T19:31:31", "url": "https://files.pythonhosted.org/packages/5b/36/6464b3caf54fc4ad285614e04ed3841acf4a1e5d7f22c64d83fd8a2880fc/xpath_validator-1.5.0.tar.gz" } ], "1.5.1": [ { "comment_text": "", "digests": { "md5": "629123fefccd4155a88ba39d2c9f1aeb", "sha256": "4f9958794da99e7ce3f41b51c9fed2ba7ea372fbde630641f6794055aacafc33" }, "downloads": -1, "filename": "xpath_validator-1.5.1.tar.gz", "has_sig": false, "md5_digest": "629123fefccd4155a88ba39d2c9f1aeb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9295, "upload_time": "2019-08-29T19:36:50", "url": "https://files.pythonhosted.org/packages/b9/e7/fc7ad2a40d51a43748ad60d049b479c420f21133a669f70ec6fac93b996e/xpath_validator-1.5.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "629123fefccd4155a88ba39d2c9f1aeb", "sha256": "4f9958794da99e7ce3f41b51c9fed2ba7ea372fbde630641f6794055aacafc33" }, "downloads": -1, "filename": "xpath_validator-1.5.1.tar.gz", "has_sig": false, "md5_digest": "629123fefccd4155a88ba39d2c9f1aeb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9295, "upload_time": "2019-08-29T19:36:50", "url": "https://files.pythonhosted.org/packages/b9/e7/fc7ad2a40d51a43748ad60d049b479c420f21133a669f70ec6fac93b996e/xpath_validator-1.5.1.tar.gz" } ] }