@illavv/run_typer - v4.1.0
    Preparing search index...

    Class TyperError

    The error every validation failure raises.

    It extends TypeError so existing catch (e) { if (e instanceof TypeError) } code keeps working, and adds issues: the structured, machine-readable list of everything that went wrong. Branch on issue.code and issue.path rather than parsing message, which is formatted for humans and may change.

    try {
    typer.parse({ id: 'number', email: 'string' }, payload);
    } catch (e) {
    if (e instanceof TyperError) {
    for (const issue of e.issues) {
    console.error(issue.path, issue.code, issue.expected, issue.received);
    }
    }
    }

    Hierarchy

    • TypeError
      • TyperError
    Index
    issues: ValidationIssue[]

    Every problem found during validation, in schema order. Never empty.

    message: string
    name: string
    stack?: string
    • Groups the issues by their dotted path — the shape most form libraries expect when mapping validation output onto fields.

      Returns Record<string, string[]>

      A record of path to the messages reported at that path.

      const result = typer.safeParse(schema, payload);
      if (!result.success) {
      const byField = (result.error as TyperError).flatten();
      // { "address.city": ["Expected \"address.city\" to be string, got number"] }
      }