Replies: 1 comment
|
The optional type comes from You're already supplying cc: z.array(z.string().email()),Keep If you need to keep The distinction is covered in the resolver's input/output type example. |
|
The optional type comes from You're already supplying cc: z.array(z.string().email()),Keep If you need to keep The distinction is covered in the resolver's input/output type example. |
The optional type comes from
.default([])oncc. It allowsundefinedas input and produces an array after parsing. React Hook Form types the field using the schema's input, sofield.valuecan beundefinedeven though your database value isstring[].You're already supplying
ccindefaultValues. If you don't need the schema itself to accept a missingcc, remove the schema default:Keep
defaultValues.ccas it is. The field is then required in the input type, and an empty array is still valid.If you need to keep
.default([])for other callers of this schema, useconst cc = field.value ?? []inside the render callback, then useccforvalues,.length, and.jo…