Open Kendaichi opened 1 month ago
Utilizing the Form Component of Shadcn, I noticed that the Input Components of type number are returning me string values.
Now I have a schema here from ZOD
likelihood_rating: z.number().int().min(1).max(5),
And this is my formField:
<FormField control={form.control} name="likelihood_rating" render={({ field }) => ( <FormItem> <FormLabel>Likelihood Rating</FormLabel> <FormControl> <Input type="number" placeholder="Likelihood Rating" {...field} autoComplete="likelihood_rating" /> </FormControl> <FormMessage className="text-end" /> </FormItem> )} />
So now because of validation I am getting this FormMessage being displayed
Is there anything I can do with this?
Input
Create a Zod Validation, that receives a number value: likelihood_rating: z.number().int().min(1).max(5),
Now create a const form utilizing the useForm:
const form = useForm({ resolver: zodResolver(registerSchema), defaultValues: { likelihood_rating: "", consequence_rating: "", rating_category: "", }, });
No response
Windows 11, Browser(Brave), CodeEditor(VSCode)
This problem does exist. When can it be fixed?
Describe the bug
Utilizing the Form Component of Shadcn, I noticed that the Input Components of type number are returning me string values.
Now I have a schema here from ZOD
likelihood_rating: z.number().int().min(1).max(5),
And this is my formField:
So now because of validation I am getting this FormMessage being displayed
Is there anything I can do with this?
Affected component/components
Input
How to reproduce
Create a Zod Validation, that receives a number value:
likelihood_rating: z.number().int().min(1).max(5),
Now create a const form utilizing the useForm:
Codesandbox/StackBlitz link
No response
Logs
No response
System Info
Before submitting