Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 549 Bytes

README.md

File metadata and controls

38 lines (27 loc) · 549 Bytes

Convince

Type safe schema validation library. Lightweight alternative to Zod.

Install

yarn add convince

Or

npm i convince

Usage

import { s, SchemaType } from 'convince';

const thingSchema = s.object({
  foo: s.string(),
  bar: s.number().optional(),
  baz: s.boolean(),
});

type Thing = SchemaType<typeof thingSchema>;

const thingResult = thingSchema.parse({
  foo: 'Hello',
  baz: true,
});

if (thingResult.ok) {
  console.log(thingResult.data.foo);
}