For the complete documentation index, see llms.txt.
Skip to main content
Version: 8.10 (unreleased)

Class: VariableMap<TSchema>

Result of a DTO-driven variable search.

Holds the parsed variable values keyed by their declared name. Provides lenient, defensive access via has / get, and a strict validate that parses the values against the schema — returning a fully-typed object or throwing a ZodError when a required variable is missing or malformed.

Type Parameters​

TSchema​

TSchema extends AnyVariableSchema

Constructors​

Constructor​

new VariableMap<TSchema>(_raw, _schema): VariableMap<TSchema>;

Parameters​

_raw​

Readonly<Record<string, unknown>>

_schema​

TSchema

Returns​

VariableMap<TSchema>

Accessors​

raw​

Get Signature​

get raw(): Readonly<Record<string, unknown>>;

The parsed variable values, keyed by variable name.

Returns​

Readonly<Record<string, unknown>>

Methods​

get()​

get<K>(variableName): K extends keyof input<TSchema> ? input<TSchema>[K] | undefined : undefined;

Lenient access. Returns the JSON-parsed wire value, or undefined when the variable is absent.

The value is not run through the schema, so a declared key is narrowed to that field's schema input type (z.input) unioned with undefined — not the post-validation output type. This keeps the type honest for schemas with transforms or effects, where the parsed wire value can differ from validate()'s output. Any other key resolves to undefined: the result only ever holds the declared variable names, so an undeclared key can never carry a value.

Type Parameters​

K​

K extends string

Parameters​

variableName​

K

Returns​

K extends keyof input<TSchema> ? input<TSchema>[K] | undefined : undefined


has()​

Call Signature​

has(variableName): boolean;

Whether a variable with the given name is present in the result.

Parameters​
variableName​

keyof input<TSchema> & string

Returns​

boolean

Call Signature​

has(variableName): boolean;

Whether a variable with the given name is present in the result.

Parameters​
variableName​

string

Returns​

boolean


validate()​

validate(): output<TSchema>;

Strict access. Parses the collected values against the schema and returns the typed object. Required variables must be present and well-formed, otherwise a ZodError is thrown.

Returns​

output<TSchema>