iway1 / react-ts-form

https://react-ts-form.com
MIT License
2.01k stars 35 forks source link

Added the missing type of the missing zod schema in missing type error #1

Closed olivier-deschenes closed 1 year ago

olivier-deschenes commented 1 year ago

Added the missing zod schema in the error thrown when a type is missing in the form mapping.

Exemple

const mapping = [[z.string(), () => <input />] as const] as const;

const Schema = z.object({
  enum: z.enum(["Yes"]),
});

const Form = createTsForm(mapping);

render ( 
  <Form schema={Schema} /> 
)

With the current error, this will throw

No matching zod schema found in mapping for property enum. (...)

With the changes, this will now throw:

No matching zod schema for type ZodEnum found in mapping for property enum. (...)

olivier-deschenes commented 1 year ago

My bad. @iway1 done 😁.

iway1 commented 1 year ago

🙏