Skip to main content
Module

x/valita/mod.ts>ValitaError

A typesafe validation & parsing library for TypeScript.
Go to Latest
class ValitaError
extends Error
import { ValitaError } from "https://deno.land/x/valita@v0.3.3/mod.ts";

An error type representing one or more validation/parsing errors.

The .message property gives a short overview of the encountered issues, while the .issue property can be used to get a more detailed list.

const t = v.object({ a: v.null(), b: v.null() });

try {
  t.parse({ a: 1 });
} catch (err) {
  err.message;
  // "invalid_type at .a (expected null) (+ 1 other issue)"

  err.issues;
  // [
  //   { code: 'invalid_type', path: [ 'a' ], expected: [ 'null' ] },
  //   { code: 'missing_value', path: [ 'b' ] }
  // ]
}

Constructors

new
ValitaError(issueTree: IssueTree)

Properties

private
optional
_issues: Issue[]
readonly
issues: readonly Issue[]