Skip to content

feat(validation): implement validate function and SchemaValidationErr… #3662

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

Merged
merged 7 commits into from
Feb 27, 2025

Conversation

VatsalGoel3
Copy link
Contributor

@VatsalGoel3 VatsalGoel3 commented Feb 26, 2025

Summary

Changes

Please provide a summary of what's being changed

This PR improves the validate function by:

Ensuring correct handling of JMESPath expressions in the envelope parameter.
Adding type safety for formats to comply with Ajv's expectations.
Adding necessary type assertions for payload validation.
Fixing potential issues related to schema compilation failures.

Additionally, it adds comprehensive unit tests to cover:

Basic validation with valid and invalid payloads.
Validation with an envelope extracting nested objects.
Handling of custom formats and external schemas.
Proper error handling when schema compilation or validation fails.

Please add the issue number below, if no issue is present the PR might get blocked and not be reviewed

Issue number: closes #3607


By submitting this pull request, 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.

…or and add comprehensive unit tests for validate function
@VatsalGoel3 VatsalGoel3 requested review from a team as code owners February 26, 2025 08:13
@VatsalGoel3 VatsalGoel3 requested a review from am29d February 26, 2025 08:13
@pull-request-size pull-request-size bot added the size/L PRs between 100-499 LOC label Feb 26, 2025
@github-actions github-actions bot added the feature PRs that introduce new features or minor changes label Feb 26, 2025
Copy link
Contributor

@dreamorosi dreamorosi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for the PR @VatsalGoel3, I left a few comments but nothing major.

--

Regarding your question about tests, I think you might've been mistakenly running both unit and end to end tests and because of this, it was trying to deploy resources to an AWS account.

If you want to run the tests for this package, use this command: npm run test:unit:coverage -w packages/validation from the root of the project.

@VatsalGoel3
Copy link
Contributor Author

I have updated the code with the required changes. Please let me know if any other changes are needed.

Thank you

Copy link
Contributor

@dreamorosi dreamorosi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for addressing the comments, a couple more things that were not addressed in the previous iteration - I made them clear.

@VatsalGoel3
Copy link
Contributor Author

Sorry for missing some changes; I updated them; also for the first line in index.ts, I had it because of the corresponding indes.test.ts; I have updated that test suite as well to match the updated index.ts

@am29d am29d removed their request for review February 27, 2025 11:25
@dreamorosi dreamorosi self-requested a review February 27, 2025 13:46
Copy link
Contributor

@dreamorosi dreamorosi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this PR!

If you're interested, you can take one between #3609 and #3608 which are a continuation of this one.

@dreamorosi dreamorosi requested a review from am29d February 27, 2025 13:48
@dreamorosi
Copy link
Contributor

@am29d need a second approval, because I made a commit to fix an import.

@dreamorosi dreamorosi merged commit f55127b into aws-powertools:main Feb 27, 2025
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature PRs that introduce new features or minor changes size/L PRs between 100-499 LOC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: standalone validate function for JSON Schema validation
3 participants