Saxonberg Server API
    Preparing search index...

    Type Alias PromptValidator<T>

    PromptValidator: (response: T) => true | string | Promise<true | string>

    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.

    Type Parameters

    • T

    Type Declaration

      • (response: T): true | string | Promise<true | string>
      • Parameters

        • response: T

        Returns true | string | Promise<true | string>