schema.ts

Helpers shared by the modules that declare output schemas (types.ts, diagnostics.ts, analyze-core.ts).

Named is the alias their schema interfaces extend through, and parseWithSummary is what the public parse* helpers throw through, so a failure names every reported issue with its path, not just the first one's text.

A leaf: it imports only valibot, so any schema module can depend on it without pulling in another.

view source

Declarations
#

parseWithSummary
#

schema.ts view source

internal

<TSchema extends v.GenericSchema>(schema: TSchema, value: unknown): InferOutput<TSchema> import {parseWithSummary} from 'svelte-docinfo/schema.js';

Validate value against schema, throwing an error that lists every issue valibot reports.

Collects all issues rather than stopping at the first, and replaces the message valibot's own parse would throw (the first issue only, with no path). The format is this package's own, built from each issue's message and v.getDotPath: one line per issue, in issue order, as path: message, or the bare message when the issue has no dot path (the root value, or a path through a key a dot path can't express).

That isn't every problem in the value: a strict object with several unknown keys reports only the first, so fixing one can surface the next.

schema

the schema to validate against

type TSchema

value

the value to validate

type unknown

returns

InferOutput<TSchema>

the parsed output, defaults applied

generics

parseWithSummary<TSchema extends v.GenericSchema>
TSchema
constraint v.GenericSchema

throws

  • ValiError - when `value` doesn't match; `message` lists the issues in the format above and `issues` holds them structured

Imported by
#