Skip to content

Conversation

abimaelmartell
Copy link
Contributor

@abimaelmartell abimaelmartell commented Dec 8, 2023

The result is undefined if you don't pass an schema


if (isFormData && willValidateRequestBody) {
req.body = input.formData?.parse(req.body)
if (isFormData && willValidateRequestBody && input.formData) {
Copy link
Member

Choose a reason for hiding this comment

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

Can isFormData contain the check for non-empty form data?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that would still work, the issue is that because of the ? conditional thing, when formData is undefined, we overwrite the req.body to undefined too.

Copy link
Member

Choose a reason for hiding this comment

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

I think if you do const isFormData = Boolean(input.formData) && input.formData then you can still remove the .?

Copy link
Contributor

@seveibar seveibar left a comment

Choose a reason for hiding this comment

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

(commenting to clear github notification- can't remove myself otherwise 🤷 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants