schema.ts

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

parseWithSummary is what the public parse* helpers throw through, so a failure names every reported issue with its path, not just the first ten, and says when the list may be cut off.

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

view source

Declarations
#

parseWithSummary
#

schema.ts view source

internal

<TSchema extends s.Schema>(schema: TSchema, value: unknown): ReturnType<TSchema["run"]> import {parseWithSummary} from 'svelte-docinfo/schema.js';

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

s.parse_or_throw's message stops at ten issues; this one lists every issue the parse builds, one per line, as s.format_issue_with_value writes it: path: expected X, received Y, or the bare text for an issue at the root, where Y is the value that failed when it's a string, number, or boolean (a string quoted as JSON and cut at 32 code units, so received "funtion"), and its type otherwise (received undefined, received object). An unknown key reads its value's type, never the value. So the message carries short pieces of value's values, which issues never does. Unknown keys of a strict object are each reported. fuz_schema builds at most a hundred issues for a parse, so a message of a hundred ends with a line saying there may be more.

schema

the schema to validate against

type TSchema

value

the value to validate

type unknown

returns

Infer<TSchema>

the parsed output, defaults applied

generics

parseWithSummary<TSchema extends s.Schema>
TSchema
constraint s.Schema

throws

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

Imported by
#