Skip to main content

Function: registerDeep()

registerDeep<S, Meta>(registry, schema, config): void

Defined in: packages/core/src/register.ts:81

Register a schema and all its nested fields in a registry using a path-structured FieldConfig tree.

Only the flat metadata fields (fieldType, order, hidden, section, props, etc.) are passed to registry.add() for each schema. The structural keys fields and arrayItems are used purely to drive the recursive walk and are never stored in the registry.

Type Parameters

S

S extends $ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>

Meta

Meta extends object

Parameters

registry

$ZodRegistry<Meta>

schema

S

config

FieldConfig<S>

Returns

void

Example

const formRegistry = z.registry<FormMeta>();

const schema = z.object({
name: z.string(),
address: z.object({ street: z.string(), city: z.string() }),
tags: z.array(z.string()),
});

registerDeep(formRegistry, schema, {
component: 'form',
fields: {
name: { component: 'Input', order: 0 },
address: {
component: 'Fieldset',
fields: {
street: { component: 'Input' },
city: { component: 'Input', hidden: true },
},
},
tags: {
component: 'ArrayField',
arrayItems: { component: 'Input' },
},
},
});

Remarks

Recursively walks a FieldConfig tree, separating traversal keys (fields, arrayItems) from flat metadata keys (component, order, hidden). Only flat keys are stored in the registry — structural keys drive the recursion. Warns on config keys that don't match schema shape (helpful for typo detection).

Use When

  • You have a deeply-nested FieldConfig mirroring your schema shape
  • Recommended for complex schemas with nested objects and arrays

Avoid When

  • For simple flat configs — registerFlat() is simpler and more direct
  • Don't use if your config comes from dot-path format (CLI global fields)

Pitfalls

  • NEVER mix with registerFlat() on the same schema — registry entries conflict silently
  • NEVER forget the structural keys (fields, arrayItems) for nested config — without them, child config is silently ignored