Skip to content

Switch instead of Checkbox for zodBoolean #159

Description

@DrummyFloyd

i'm migrating from the standalone version

and 'im wondering how can i achieve this old (custom) behaviour for boolean on zod instance

on my standalone auto-form cnfig.ts

i've set this

/**
 * Define handlers for specific Zod types.
 * You can expand this object to support more types.
 */
export const DEFAULT_ZOD_HANDLERS: {
  [key: string]: keyof typeof INPUT_COMPONENTS;
} = {
  ZodBoolean: "switch", // change default here
  ZodDate: "date",
  ZodEnum: "select",
  ZodNativeEnum: "select",
  ZodNumber: "number",
};

how can i achieve to this easily with the new version , =)

EDIT:

i tried this but seems to no work

z.object({
  name: z.string(),
  age: z.coerce.number(),
  isHuman: z.boolean().superRefine(
    fieldConfig({
      fieldType: "switch",
    })
  )
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions