You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know i18n is still new on valibot, i open this issue just to think about it.
Client side validation is not translated if globally set by v.setGlobalConfig({ lang: "en" }); and we currently can't pass options to valiForm() to set it locally.
Could be resolved by getting the global config in _parse() or use safeParse() which internally use _parse(input, getGlobalConfig(config));.
The text was updated successfully, but these errors were encountered:
There is a small problem. Valibot is currently only a dev dependency of Modular Forms. Therefore I can only import types and not JavaScript functions like safeParse or getGlobalConfig. To be able to import it, I have to add Valibot as a peer dependency, but this would trigger a warning for any user using Modular Forms without Valibot.
The bigger problem is the current structure of Modular Forms packages. Normally I should release the adapters as a separate package. I plan to improve this when I rewrite the entire library, but that will take some time. For now, as a workaround, I recommend adding the updated valiForm adapter to your source code:
importtype{FieldValues,ValidateForm,PartialValues,FormErrors,}from'@modular-forms/solid';import{typeBaseSchema,typeBaseSchemaAsync,safeParseAsync}from'valibot';/** * Creates a validation functions that parses the Valibot schema of a form. * * @param schema A Valibot schema. * * @returns A validation function. */exportfunctionvaliForm<TFieldValuesextendsFieldValues>(schema: BaseSchema<TFieldValues,any>|BaseSchemaAsync<TFieldValues,any>): ValidateForm<TFieldValues>{returnasync(values: PartialValues<TFieldValues>)=>{constresult=awaitsafeParseAsync(schema,values,{abortPipeEarly: true,});returnresult.issues
? result.issues.reduce<FormErrors<TFieldValues>>((errors,issue)=>({
...errors,[issue.path!.map(({ key })=>key).join('.')]: issue.message,}),{})
: {};};}
Hello,
I know i18n is still new on valibot, i open this issue just to think about it.
Client side validation is not translated if globally set by
v.setGlobalConfig({ lang: "en" });
and we currently can't pass options tovaliForm()
to set it locally.Could be resolved by getting the global config in
_parse()
or usesafeParse()
which internally use_parse(input, getGlobalConfig(config));
.The text was updated successfully, but these errors were encountered: