Skip to content

LoadConfigOptions

LoadConfigOptions<T> = object

Defined in: types.ts:110

Configuration for loadConfig.

T

optional includeValuesInErrors?: boolean

Defined in: types.ts:123

If true, the validation error message includes the values that failed, and ValidationErrorContext.merged is passed to LoadConfigOptions.onValidationError. Off by default to avoid logging secrets.


optional logger?: ConfigLogger

Defined in: types.ts:116

Optional logger for diagnostics.


optional mode?: ValidationMode

Defined in: types.ts:128

Validation failure behaviour. Defaults to "strict" (throw). See ValidationMode.


optional onSourceError?: (error, info) => void

Defined in: types.ts:145

Diagnostic hook called when a source’s load() throws. The error is still soft-handled (treated as an empty source) so other sources continue to load — this hook is purely for observability.

unknown

SourceErrorInfo

void


optional onValidationError?: (error, context) => Error | void

Defined in: types.ts:139

Hook called with the raw validation error before config-kit decides what to do with it. Use it to inspect Zod issues, attach the config file path, or render a custom message.

Return an Error to use it instead of config-kit’s default (redacted) error — that Error is thrown in strict mode or logged in warn mode. Return nothing to keep the default behaviour.

unknown

ValidationErrorContext

Error | void


schema: Schema<T>

Defined in: types.ts:112

Schema used to validate and shape the merged config.


sources: AnyConfigSource[]

Defined in: types.ts:114

Sources merged in order. Later sources override earlier.