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

Un-correct parse data with Joi schema #531

Open
1 task done
phongtran11 opened this issue Dec 17, 2024 · 3 comments
Open
1 task done

Un-correct parse data with Joi schema #531

phongtran11 opened this issue Dec 17, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@phongtran11
Copy link

  • Before posting an issue, read the FAQ and search the previous issues.

Description
function superValidate return not correct data.

id was undefined as result of superValidate . Note this occurred with id = 7
image

Schema:
image

It can resolve by use parseInt:
image

But with id = 79, it's not happed
image

Can someone give me the root cause.
Thank alot

If applicable, a MRE
Use this template project to create a minimal reproducible example that you can link to here: https://sveltelab.dev/github.com/ciscoheat/superforms-examples/tree/zod (right click to open in a new tab)

@phongtran11 phongtran11 added the bug Something isn't working label Dec 17, 2024
@ciscoheat
Copy link
Owner

It's could be because since id is not required in the schema, when it failed validation it returned the default value for a non-required field, in this case undefined.

@phongtran11
Copy link
Author

It's could be because since id is not required in the schema, when it failed validation it returned the default value for a non-required field, in this case undefined.

Thank for your reply. But i see your explain not show the root cause.
Could you reason why validate with '7' but not with '79'

@ciscoheat
Copy link
Owner

Not really, can you make a MRE so I can take a closer look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants