Skip to main content

Variable: decision

const decision: object

Defined in: packages/core/src/decision-schema.ts:99

The decision-shaped Zod fields, grouped for a readable call site.

import { decision } from '@baleybots/core';

const schema = z.object({
category: decision.choice(['billing', 'technical']),
urgency: decision.score(['Routine', 'Urgent']),
refund: decision.check(),
});

Type Declaration

check

readonly check: () => ZodType<boolean> = checkField

A yes/no field. Present for symmetry — a plain z.boolean() is identical.

Returns

ZodType<boolean>

choice

readonly choice: {<T>(labels): ZodType<T[number]>; <T>(criteria): ZodType<Extract<keyof T, string>>; } = choiceField

Call Signature

<T>(labels): ZodType<T[number]>

A choice field: one of these labels. Use a map only to describe labels.

category: choiceField(['billing', 'technical', 'other'])

Emits a union of described literals, so the descriptions survive into JSON Schema as each member's description — standard, not a private extension.

Type Parameters
T

T extends readonly string[]

Parameters
labels

T

Returns

ZodType<T[number]>

Call Signature

<T>(criteria): ZodType<Extract<keyof T, string>>

A choice field: one of these labels. Use a map only to describe labels.

category: choiceField(['billing', 'technical', 'other'])

Emits a union of described literals, so the descriptions survive into JSON Schema as each member's description — standard, not a private extension.

Type Parameters
T

T extends Record<string, string | null>

Parameters
criteria

T

Returns

ZodType<Extract<keyof T, string>>

score

readonly score: <T>(labels) => ZodType<number> = scoreField

A score field: an expectation over an ordered rubric.

urgency: scoreField(['Routine', 'Worth a look', 'Urgent'])

The answer is a number from 0 to labels.length - 1 and may be fractional0.75 means "between the first and second level, nearer the second". That is why this is not an integer field: an integer schema would reject the answers its own question produces.

The rubric rides in JSON Schema metadata, which is the only place a per-level description can live on a numeric field.

Type Parameters

T

T extends readonly [string, string, string]

Parameters

labels

T

Returns

ZodType<number>