MCPcopy Create free account
hub / github.com/better-auth/examples / getBaseSchema

Function getBaseSchema

nuxt-example/components/ui/auto-form/utils.ts:38–49  ·  view source on GitHub ↗
(schema: ChildType | z.ZodEffects<ChildType>)

Source from the content-addressed store, hash-verified

36 * This will unpack optionals, refinements, etc.
37 */
38export function getBaseSchema<
39 ChildType extends z.ZodAny | z.AnyZodObject = z.ZodAny,
40>(schema: ChildType | z.ZodEffects<ChildType>): ChildType | null {
41 if (!schema) return null;
42 if ("innerType" in schema._def)
43 return getBaseSchema(schema._def.innerType as ChildType);
44
45 if ("schema" in schema._def)
46 return getBaseSchema(schema._def.schema as ChildType);
47
48 return schema as ChildType;
49}
50
51/**
52 * Get the type name of the lowest level Zod type.

Callers 1

getBaseTypeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected