Skip to main content

Request Filter Groups

Description

A Python wrapper and utility function for validating requests.

The funtions takes a list of dictionaries containing JSON paths keys to search for the attribute to validate and filter rule values to validate the attributes with. Under the hood, the validation process uses Validator to validate the JSON path values with the Validator rules. If atleast one filter group is validated, then the funcion returns True. List of possible Validator rules can be found here:

Examples

Decorator:

Succeeded Validation

r = RequestFilter()

@r.request_filter_groups([
    {
        "A.B": "regex:foo",
        "C": "required|min:3"
    }
])
def func(data):
    # <response logic>
    return {"statusCode": 200}

request_data = {
    "A": {"B": "foo"},
    "C": [1, 2, 3]
},

response = func(data)

Returns dummy func() return value:

{"statusCode": 200}

Failed Validation

r = RequestFilter()

@r.request_filter_groups([
    {
        "A.B": "regex:foo",
        "C": "required|min:10"
    }
])
def func(data):
    # <response logic>
    return {"statusCode": 200}

request_data = {
    "A": {"B": "foo"},
    "C": [1, 2, 3]
},

response = func(data)

Returns validate() return value

{'statusCode': 422, 'body': ValidationError({'C': {'Min': 'Expected Maximum: 10, Got: 3'}})}

Installation

Package can be found on PyPI

pip install request-filter-groups

TODO:

  • Add Flask-related tests

Metadata

Release files for request-filter-groups 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for request-filter-groups 0.0.4
File Size Uploaded Provenance
request-filter-groups-0.0.4.tar.gz 3.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for request-filter-groups 0.0.4
File Interpreter ABI Platform
request_filter_groups-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 6.5 kB

Release files / request-filter-groups-0.0.4.tar.gz

Download URL request-filter-groups-0.0.4.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b274c50a855b991522e296b95e6e93a162083514410623e95033860ae75c0b37
BLAKE2b-256 checksum
How to use checksums
9ffae5068718660c6b9e820579e66368589f3f5f91a59b0feb052161c9e48350
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / request_filter_groups-0.0.4-py3-none-any.whl

Download URL request_filter_groups-0.0.4-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ebfcd2c56cd25f3a5c274b20b8c2f3017087d21dce5a5e54157df92ada8636c
BLAKE2b-256 checksum
How to use checksums
2a5e38d932d788421a5b221f504eec34909f124d889bc0de500eec5ee7c884c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Security for request-filter-groups 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page