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

feat(ajv): add returnsCoercedValues option to keep the coerced value by ajv #2504

Merged
merged 3 commits into from
Nov 2, 2023
Merged

feat(ajv): add returnsCoercedValues option to keep the coerced value by ajv #2504

merged 3 commits into from
Nov 2, 2023

Conversation

EinfachHans
Copy link
Contributor

@EinfachHans EinfachHans commented Nov 2, 2023

Information

Type Breaking change
Fix No ?

closes #2497

With this PR the result of a Validation is correctly returned. The resulted data can be different from the input data, when the validation modifies it, which is a common usage.

This is my first PR to this awesome project. Please let me know if i'm missing something 🤔

Todos

  • Tests
  • Coverage
  • Example
  • Documentation

@Romakita
Copy link
Collaborator

Romakita commented Nov 2, 2023

@EinfachHans thanks for the PR. Just a small change to optimize the code ;)

see you

@EinfachHans
Copy link
Contributor Author

@Romakita okay somehow an integration test is now failing. Didn't know why it worked locally first...

Anyways, the test that fails is Scenario8 in testBodyParams.ts, which tests a null model input should return the null model back. I'm unsure about this test, can you have a look?

@Romakita
Copy link
Collaborator

Romakita commented Nov 2, 2023

Yes I take a look. This test is here to check if the null value is keep through after validation and deserialization depending on the endpoint configuration.
This one of the side effect of ajv.
I’ll check if it’s pertinent or not.

@Romakita
Copy link
Collaborator

Romakita commented Nov 2, 2023

Ok I already given information on this issue and why isn't fixable easily:
#2355

@EinfachHans
Copy link
Contributor Author

Mhh, so should i close this PR?

@Romakita
Copy link
Collaborator

Romakita commented Nov 2, 2023

@EinfachHans I fixed the problem by introducing a new ajv options returnsCoercedValues.

Can you review the latest commits please ;)

@Romakita
Copy link
Collaborator

Romakita commented Nov 2, 2023

This PR will solve your issue and another issue related to the coerced value by ajv! Good news :D

@EinfachHans
Copy link
Contributor Author

@Romakita awesome, Thanks! 🚀
Code makes totally sense and documentation is quite clear or me 👍🏼

@EinfachHans EinfachHans changed the title fix: validation returns resulted data feat(ajv): add returnsCoercedValues option to keep the coerced value by ajv Nov 2, 2023
@Romakita
Copy link
Collaborator

Romakita commented Nov 2, 2023

Ok fixed issue on my local. It should be ok to merge and release after that ;)

@Romakita Romakita merged commit 4e81a12 into tsedio:production Nov 2, 2023
2 of 16 checks passed
@Romakita
Copy link
Collaborator

Romakita commented Nov 2, 2023

🎉 This PR is included in version 7.43.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@EinfachHans EinfachHans deleted the fix/issue-2497 branch November 2, 2023 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Body Validation not working as expected
2 participants