-
Notifications
You must be signed in to change notification settings - Fork 549
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(Form): update and migrate valibot
to v0.31.0
#1848
Conversation
valibot
to v0.31.0
Thanks a lot @fabian-hiller for taking the time to help us with this and for creating this awesome library! π |
Does it also resolve #625 ? |
package.json
Outdated
@@ -54,6 +54,7 @@ | |||
"nuxt-icon": "^0.6.10", | |||
"ohash": "^1.1.3", | |||
"pathe": "^1.1.2", | |||
"valibot": "^0.31.0", |
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.
Valibot should be an opt-in dependency to promote flexibility in validation library selection and minimize dependencies. It should stay as a dev dependency.
})) | ||
} | ||
return [] | ||
const result = await valibotParse(schema, state) |
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.
Is there a way to include the parse function inside the schema object so we can fix issues related to the use of _parse
without a direct dependency to valibot
?
When Valibot was first added, a dynamic import was used to use Back then this was ok because We now have two alternatives, the first is to add Valibot as a dependency to Nuxt UI to be able to import const schema = v.object({
email: v.string(),
password: v.string()
})
<UForm :schema="v.safeParser(schema)" ... /> @danielroe recommended via Discord to just add Valibot as a dependency because it makes it easier to use, but in the end both solutions work. |
I understand your point but the |
Thanks for the explanation! I think the using the |
Yes, that's the problem. i18n doesn't work that way.
Since Valibot is still v0, a breaking change should be ok for Valibot users, but we can of course support both. We could also support all 3 options:
Please let me know what you decide. |
Adding support for the three options looks like a great compromise. We'll be able to cleanly drop support for versions below 0.31.0 in our next major release. |
I have updated the implementation. |
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.
Thanks @fabian-hiller π
package.json
Outdated
@@ -71,7 +71,8 @@ | |||
"release-it": "^17.3.0", | |||
"typescript": "^5.4.5", | |||
"unbuild": "^2.0.0", | |||
"valibot": "^0.30.0", | |||
"valibot30": "npm:[email protected]", | |||
"valibot31": "npm:valibot@^0.31.1", |
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.
Shouldn't it be better for typings to keep the latest version as valibot
?
"valibot31": "npm:valibot@^0.31.1", | |
"valibot": "^0.31.1", |
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.
I believe there is no difference. I just followed a StackOverflow discussion to install two different versions of the same package. If we change the package name, we also need to update the import statement.
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.
Yeah in the Form.vue
component we could import from valibot30
and valibot
(instead of valibot31
).
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.
Done
Thanks @fabian-hiller! π |
Resolves #1849
β Type of change
π Description
I am the author of Valibot and have updated and migrated Nuxt UI to our latest version: https://valibot.dev/blog/valibot-v0.31.0-is-finally-available/
π Checklist