Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 of 2 tasks
dracozombie19 opened this issue Jul 22, 2024 · 5 comments · Fixed by #4839
Closed
1 of 2 tasks

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

dracozombie19 opened this issue Jul 22, 2024 · 5 comments · Fixed by #4839
Labels
feature-request feature request validator Validation (JSON Schema) utility

Comments

@dracozombie19
Copy link
Contributor

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

@dracozombie19 dracozombie19 added feature-request feature request triage Pending triage from maintainers labels Jul 22, 2024
Copy link

boring-cyborg bot commented Jul 22, 2024

Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

@heitorlessa
Copy link
Contributor

heitorlessa commented Jul 22, 2024 via email

@heitorlessa heitorlessa added validator Validation (JSON Schema) utility and removed triage Pending triage from maintainers labels Jul 22, 2024
@heitorlessa heitorlessa moved this from Triage to Ideas in Powertools for AWS Lambda (Python) Jul 22, 2024
@heitorlessa heitorlessa moved this from Ideas to Backlog in Powertools for AWS Lambda (Python) Jul 22, 2024
@dracozombie19
Copy link
Contributor Author

I did some work on this last week but ran into trouble getting the tests to run in the cloud development environment for some reason. I'll try to revisit it this week.

@dracozombie19
Copy link
Contributor Author

See: #4839

Copy link
Contributor

github-actions bot commented Aug 6, 2024

⚠️COMMENT VISIBILITY WARNING⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

@leandrodamascena leandrodamascena moved this from Coming soon to Shipped in Powertools for AWS Lambda (Python) Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request feature request validator Validation (JSON Schema) utility
Projects
Status: Shipped
Development

Successfully merging a pull request may close this issue.

2 participants