-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
Use zod for validation on create endpoint #1391
Conversation
Important Auto Review SkippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the To trigger a single review, invoke the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
I think this works. Zod can also handle validation on the lengths and stuff and there is a library called zod-validation-error which can give nicer errors from what I was reading. Let me know if you want any changes/if I missed anything. edit: Also, the checks are repeated since I didn't know which you would prefer. |
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.
Ideally, we gut all the manual validation we are doing and replace it all with zod.
How does this make sure that createRoomSchema
stays in sync with the type definition OttApiRequestRoomCreate
? Failing to do so will cause problems in the future.
And make the PR title more descriptive.
I'll move as much of the validation as I can to Zod. So |
I remember seeing a It might be a good idea to move the zod schemas to ott-common instead, depending on how badly it impacts the bundle size. Vitest also has a thing to test types that would also work. |
If you find it necessary I can move the zod schemas to ott-common, just give me the confirmation. I will also take a look at Vitest testing types thing. |
Sounds good, but I want to see how badly it affects the bundle size when you build |
Is there any difference in functionality if |
Seems like they are basically the same thing. https://stackoverflow.com/questions/37233735/interfaces-vs-types-in-typescript |
Adding anything to |
It was because zod got removed from |
Little stumped on why the error handler isn't catch the zod error. Also, even when I wrap the schema parsing in a try catch, the request is succeeding in the tests and I can't for the life of me find out why. If you could push me in the right direction/not straight up give me the answer that would be great. |
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1391 +/- ##
================================================
+ Coverage 54.1619% 55.9188% +1.7569%
================================================
Files 158 162 +4
Lines 24652 24743 +91
Branches 1437 1416 -21
================================================
+ Hits 13352 13836 +484
+ Misses 11243 10853 -390
+ Partials 57 54 -3 ☔ View full report in Codecov by Sentry. |
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.
Looks good. Just a couple of easy fixes.
Why do |
They weren't in there because the type wasn't complete. They need to be in there because those are all the fields that are shown in the UI when creating a permanent room. You will find this to be the case for most of the rest api types. |
Ah okay, makes sense. Forgot to remove those, will do that now. |
Passing run #1218 ↗︎
Details:
Review all test suite changes for PR #1391 ↗︎ |
related to #1339