Skip to content

Feature request: validate() to return validated payload #4797

Closed
@dracozombie19

Description

@dracozombie19

Use case

The Validation feature in Powertools uses fastjsonschema.validate() to perform the validation. This function in fastjsonschema returns the validated payload. While usually this is exactly the same as the input payload, fastjsonschema also populates default values in missing fields. For example, with this schema:

{
  "properties": {
   "required_id": {
    "type": "integer"
   },
   "test_default": {
    "type": "string",
    "default": "def"
   }
  },
  "required": [
   "required_id"
  ],
  "type": "object"
}

And this payload:

{
  "required_id": 1234
}

The validate() function will return:

{
  "required_id": 1234,
  "test_default": "def"
}

Solution/User Experience

I'm wondering if we can have the Powertools validate() function return the results from fastjsonschema.validate().

Alternative solutions

No response

Acknowledgment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Shipped

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions