-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Description
This schema uses default values.
export const buttonSchema = object({
id: number().default(uniqueID),
text: string().nonempty().trim().default(''),
background: string().nonempty().default('#000000'),
color: string().nonempty().default('#ffffff'),
})
useForm({
validationSchema: toTypedSchema(popupSchema.merge(object({
buttons: buttonSchemaWithUrl.array().default([]),
}))),
})When I define the buttons field, I get these types.
const [buttons] = defineField('buttons', {})
// type
const buttons: Ref<{
url: string;
id?: number | undefined;
text?: string | undefined;
background?: string | undefined;
color?: string | undefined;
}[] | undefined, {
url: string;
id?: number | undefined;
text?: string | undefined;
background?: string | undefined;
color?: string | undefined;
}[] | undefined>But when i remove default values
const buttons: Ref<{
id: number;
text: string;
background: string;
color: string;
url: string;
}[] | undefined, {
id: number;
text: string;
background: string;
color: string;
url: string;
}[] | undefined>Is this expected behavior? I want default values for my form and none-null types
Metadata
Metadata
Assignees
Labels
No labels