Skip to content

Add Validation Schema Examples #386

Closed
@PixelAmp

Description

@PixelAmp

What were you initially searching for in the docs?
I wanted to implement the Validation utility to validate data received by my requests, but was unfamiliar with writing JSONSchema.

Is this related to an existing part of the documentation? Please share a link
https://awslabs.github.io/aws-lambda-powertools-python/latest/utilities/validation/

There are no working examples of valid json_schema_dict within the documentation.
They are all collapsed making it difficult to get an idea for how JSONSchema should be structured.

json_schema_dict = {..}

Describe how we could make it clearer
The fastjsonschema library is linked, however an actual example within this documentation page would make improve comprehension.

For example Unwrapping events prior to validation has sample_wrapped_event.json, but it does not show what the accompanying schema should look like.

If you have a proposed update, please share it here
I suggest adding a tab with some example inputs and their schema. as well as adding what a SchemaValidationError exception looks like for different scenarios.

For example, the a rudimentary validation schema for sample_wrapped_event.json would likely look like this (but with better regex and pattern matching)

json_schema_dict = {
    "type": "object",
    "properties": {
        "id": {"type": "string"},
        "detail-type": {"type": "string"},
        "source": {"type": "string"},
        "account": {"type": "string"},
        "time": {"type": "string"},
        "region": {"type": "string"},
        "resources": {"type": "string"},
        "detail": {
            "type": "object",
            "properties": {
                "message": {"type": "string"},
                "username": {"type": "string"},
            }
        }
    }
}

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentation

Type

No type

Projects

Status

Triage

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions