Skip to main content

Function: configField()

function configField<V>(parser, meta): ConfigField<V>;

Defined in: packages/overcast-core/src/config-schema.ts:107

Declare one field of a config schema: how its string is parsed, and how the hosts reading it name and describe it.

parser is whatever the host has to be told — z.coerce.number() for a numeric field, z.enum([...]) for a closed set, a .regex()d string for an address — rather than leaving it to be discovered when viem or anchor rejects the value under an unrelated message.

The .optional() is applied here, not by the caller, for two reasons: every field of a config schema is optional (a host states what it knows), and metadata does not survive being wrapped, so .optional() after .register() would silently discard it. One place decides the order.

Type Parameters

Type Parameter
V

Parameters

ParameterType
parserZodType<V, unknown>
metaConfigMeta

Returns

ConfigField<V>