Closed zernonia closed 1 year ago
Vee-Validate or Formkit?
Not sure. Both are great form framework, but 2 different approach 🙈
Hello! @zernonia I was wondering how should I approach this, I was thinking of using zod and native form tag to build this example, but now you mentioned Vee-Validate and FormKit. Should I wait until we implement the Form component like the one in shadcn-ui or just use zod and native form tag?
I suggest let's go with Veelidate + Zod.
Reason:
Hope you agree with me @ahmedmayara 😁
Works for me! But first I'll try to build the Form component using VeeValidate and Zod, then I will use it to build the forms example.
That'll be awesome! Looking forward to it!! 🚀
@zernonia @ahmedmayara How to use custom messages for validation? I did smth like this:
const postSchema = toTypedSchema(
z.object({
title: z.string().min(5, { message: "Iltimos 5tadan ko'p belgi kiriting." }),
body: z.string().min(15, { message: "Iltimos hech bo'lmasa 15ta belgi kiriting." })
})
)
But it is not working and even now showing "Required". How to handle this issue? Please add an example of handling this to the docs. Because, what everyone needs is that. No one uses default "Required" text if not in some rare cases. Because, everyone wants to show what's the exact error.
@otabekoff use discussion instead, this is an old issue
https://stackblitz.com/edit/rlaz3q?file=src%2FApp.vue
If you want custom required message you can do something like
const formSchema = toTypedSchema(
z.object({
username: z
.string({
required_error: 'Password is required', ///////
})
.min(5, { message: 'Please enter more than 5 characters.' }),
})
);
Describe the feature
Let's populate this page https://www.shadcn-vue.com/examples/forms.html with example 😁
reference: https://github.com/shadcn-ui/ui/tree/main/apps/www/app/examples/forms
Additional information