{"id":15584289,"url":"https://github.com/ableinc/validrequest","last_synced_at":"2025-07-25T23:14:21.383Z","repository":{"id":65181147,"uuid":"585292899","full_name":"ableinc/validrequest","owner":"ableinc","description":"This is a request handler validation tool for RESTful API endpoints.","archived":false,"fork":false,"pushed_at":"2023-11-04T15:34:33.000Z","size":54,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-05T10:46:06.863Z","etag":null,"topics":["ableinc","api-endpoints","api-rest","http-requests","library","server","validation","validation-tool"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ableinc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-01-04T20:02:50.000Z","updated_at":"2023-06-15T16:44:14.000Z","dependencies_parsed_at":"2023-01-07T07:36:29.578Z","dependency_job_id":"3afad833-fcd4-4fc6-93a4-e4204b40a7d8","html_url":"https://github.com/ableinc/validrequest","commit_stats":{"total_commits":27,"total_committers":1,"mean_commits":27.0,"dds":0.0,"last_synced_commit":"918f8cd84e9c1297118c65fa62b0f60792bdd71a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ableinc%2Fvalidrequest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ableinc%2Fvalidrequest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ableinc%2Fvalidrequest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ableinc%2Fvalidrequest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ableinc","download_url":"https://codeload.github.com/ableinc/validrequest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246162117,"owners_count":20733355,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ableinc","api-endpoints","api-rest","http-requests","library","server","validation","validation-tool"],"created_at":"2024-10-02T20:40:36.870Z","updated_at":"2025-03-29T08:44:54.730Z","avatar_url":"https://github.com/ableinc.png","language":"Python","readme":"# Validator\n\nThis is a request handler validation tool for RESTful API endpoints.\n\n## How To Use\n\n```python\nfrom validrequest import validator, ValidationError\nfrom typing import Dict, Any\n\ndef request_handler(request, response, next):\n    # Note: type and state must be the first rules in that order\n    # i.e. type (string,float,integer,number,dict)|state (required,sometimes)\n    validation_rules: Dict[str, str] = {\n        \"q\": \"string|required|max:100\",\n        \"timestamp\": \"float|sometimes|min:1|max:13\",\n        \"comment\": \"string|required|min:10\",\n        \"code\": \"integer|required\",\n        \"version\": \"float|sometimes\",\n        \"metadata\": \"dict|required\",\n        \"timeSince\": \"number|required\"\n    }\n    request_parameters: Dict[str, Any] = request.body\n    try:\n        validator(validation_rules, request_parameters)\n        return response.status(200).send(\"Validation successful.\")\n    except ValidationError as e:\n        return next({ \"message\": e })\n    except Exception:\n        return next({ \"message\": \"Something else went wrong.\" })\n\n    # You can also use a decorator (@validate) - see demo.py for an example\n```\nRefer to the ```demo.py``` file for further implementations.\n\n## How to Install\n\n```bash\npython -m pip install validrequest\n```\n\n```bash\npython -m pip install git+https://github.com/ableinc/validrequest.git\n```\n\n## Important - Migrating from v0.0.3 to v1.0.0\n\n**Breaking Changes** in Version 1.0.0 - Please carefully review the changes below\n\n- import library name has changed from \"validator\" to \"validrequest\":\n    ```python\n    from validrequest import validate, validator, ValidationError\n    ```\n- @validate decorator now accepts 'request' or 'req' as Request argument name\n- parse_level was changed to payload_level for @validate decorator\n- error callback must be named \"next\" for @validate decorator - it will not accept any other argument\n- error callback will return a string error message with error type - it will no longer return JSON\n- strict declaration has been removed - validation rules will always be checked against required and ignored for sometimes\n- 'number' is now an acceptable type in validation rule - this can be used for fields that may be either integer or float\n- Acceptable types in validation rules:\n    - Integer: int | integer | number\n    - Float: float | number\n    - String: str | string\n    - Dictionary: dict | dictionary | object\n    - Boolean: bool | boolean\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fableinc%2Fvalidrequest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fableinc%2Fvalidrequest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fableinc%2Fvalidrequest/lists"}