-
Notifications
You must be signed in to change notification settings - Fork 525
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
fix:(Form):Problem with parse translation message in issues use Valibot in form #1783
Conversation
import type { ObjectSchemaAsync as ValibotObjectSchema } from 'valibot' | ||
import { | ||
type ObjectSchemaAsync as ValibotObjectSchema, | ||
safeParseAsync as ValibotParseAsync |
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.
We can't have a direct import to valibot here, because we don't want to include it as a dependency (See this PR: #617), that's why we used ._parse
in the first place. We need to find another way around.
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 for answer, do you can see comment @fabien-hiller in issue ?
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.
In PR #617 valibot is not included in dependencies:
Now valibot included:
I'm sorry, i try explore in details this question
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.
What he meant is as long as no direct import to this dependency is done (except for import type
) valibot
is not included in the build. I believe you can bypass this import by using a dynamic import in your function like this:
safeParseAsync as ValibotParseAsync |
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.
What he meant is as long as no direct import to this dependency is done (except for
import type
)valibot
is not included in the build. I believe you can bypass this import by using a dynamic import in your function like this:
Oh, thanks! I check it later and return with answer!
@@ -264,7 +267,7 @@ async function getValibotError ( | |||
state: any, | |||
schema: ValibotObjectSchema<any> | |||
): Promise<FormError[]> { | |||
const result = await schema._parse(state) | |||
const result = await ValibotParseAsync(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.
I'm not sure if that works after building
const result = await ValibotParseAsync(schema, state) | |
const { safeParseAsync } = await import('valibot') | |
const result = await safeParseAsync(schema, state) |
π Linked issue
Resolves #1782
β Type of change
π Description
This pull request solves the problem with translations messages in valibot
π Checklist