1.3.1 • Published 1 year ago

runtypes-pretty-validation v1.3.1

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

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.

1.3.1

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago