-
Notifications
You must be signed in to change notification settings - Fork 153
feat(validation): Add Middy.js middleware for JSON Schema validation #3694
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
feat(validation): Add Middy.js middleware for JSON Schema validation #3694
Conversation
…alGoel3/powertools-lambda-typescript into feature/validator-decorator
…alGoel3/powertools-lambda-typescript into feature/validator-decorator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @VatsalGoel3 could you please rebase the branch with the current main
so it removes the conflicts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR, I left some minor comments
|
@dreamorosi, I have made the requested changes and updated the test file as well, let me know if any more improvements are needed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this PR @VatsalGoel3!
We won't be releasing this module in the next release (this Friday) because we already have another feature coming up and we won't have time to review the documentation but I expect to include it in the next one (in ~2.5 weeks).
Over the next few days I'll be adding a few more issues to the backlog, in addition to the ones that are already marked as help-wanted
(admittedly not many at the minute).
So keep an eye on the repo if you're interested in working on more!
@aws-powertools/lambda-typescript No related issues found. Please ensure 'pending-release' label is applied before releasing. |
@dreamorosi Thank you for the update, I would like to contribute more to the project or any relevant projects if possible, also is there any better way I can keep in contact with you, for better workflow. I'll keep a lookout for the coming issues. |
Summary
This PR introduces a
validationMiddleware
function for Middy.js, enabling JSON Schema validation for both inbound (event) and outbound (response) payloads in AWS Lambda functions. This middleware leverages the existingvalidate
function to ensure input and output payloads adhere to defined schemas, improving type safety and error handling in serverless applications.Changes
validationMiddleware.ts
, which:before
hook) to validate event payloads.after
hook) to validate Lambda responses.inboundSchema
noroutboundSchema
is provided.index.ts
to export thevalidationMiddleware
.middleware.test.ts
to ensure 100% test coverage, verifying:Issue number closes #3609
Checklist
any
)By submitting this pull request, I confirm that I have read and followed the Powertools for AWS Lambda (TypeScript) contributing guidelines, and I confirm that you can use, modify, copy, and redistribute this contribution under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.