runtypes-pretty-validation
TypeScript icon, indicating that this package has built-in type declarations

1.3.1 • Public • Published

runtypes-pretty-validation

validate runtypes schemas against a value, and reflect back a pretty validation report, matching the schema. Prettyifies structural error messages arbitrarily deep.

import { validate } from "runtypes-pretty-validation";
const schema = rt.Record({ foo: rt.Literal("bar") });
validate(schema, null); // Expected object, got "null"
validate(schema, { bar: "bar" }); // { foo: 'Expected literal `bar`, but was `undefined`' }
validate(schema, { foo: "bar" }); // undefined, all valid

main

install

npm install runtypes-pretty-validation

options

Options may be specified. See ./index.ts for defaults.

validate(schema, value[, opts])
  • useFirstUnionSchemaOnFail: boolean: if a validation fails all union members, report the schema validation errors from the first schema in the union.

examples

see test.ts for more.

Package Sidebar

Install

npm i runtypes-pretty-validation

Weekly Downloads

0

Version

1.3.1

License

ISC

Unpacked Size

7.66 kB

Total Files

4

Last publish

Collaborators

  • wa11-e