Validator predicate for PromptApi push opts. Returning true
resolves the await; returning a string (or a Promise that
resolves to one) keeps the prompt alive and emits a
prompt-validation-failed envelope carrying the message — the
client renders the error inline and awaits a fresh response.
Async-permitted — unlike command validators (which are
sync-by-design because the dispatcher's validator pass is sync),
prompt validators run inside the prompt's already-async
lifecycle. Returning Promise<true | string> works naturally;
DB-uniqueness checks and external-service look-ups have a home
here without a sync + preload pattern.
Substrate cancellation safety: if a prompt is cancelled while a
validate is in flight, the substrate discards the validator's
eventual result (a cancelled flag on the resolver record
prevents the late resolve call).
The validator sees the typed result T, not the raw wire
string. For confirm, that's boolean; for mqlObject,
Stuff | null; for mqlMany, Stuff[]. The substrate handles
the wire-string-to-T decoding (including mqlMany bounds
enforcement and mqlObject stuffId lookup) BEFORE running the
validator.
Validator predicate for
PromptApipush opts. Returningtrueresolves the await; returning a string (or a Promise that resolves to one) keeps the prompt alive and emits aprompt-validation-failedenvelope carrying the message — the client renders the error inline and awaits a fresh response.Async-permitted — unlike command validators (which are sync-by-design because the dispatcher's validator pass is sync), prompt validators run inside the prompt's already-async lifecycle. Returning
Promise<true | string>works naturally; DB-uniqueness checks and external-service look-ups have a home here without a sync + preload pattern.Substrate cancellation safety: if a prompt is cancelled while a validate is in flight, the substrate discards the validator's eventual result (a
cancelledflag on the resolver record prevents the lateresolvecall).The validator sees the typed result T, not the raw wire string. For
confirm, that'sboolean; formqlObject,Stuff | null; formqlMany,Stuff[]. The substrate handles the wire-string-to-T decoding (includingmqlManybounds enforcement andmqlObjectstuffId lookup) BEFORE running the validator.