tysch
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

tysch

Typed schema with run-time validation

Install

yarn add tysch

Use

import {
  type as t,
  Static,
  validate,
  isError
} from 'tysch'

const userSchema = t.object({
  name: t.string(),
  points: t.number(),
})

type UserSchema = Static<typeof userSchema>

const validData = {
  name: 'me',
  points: 1
}

const result = validate(validData, userSchema)

if (isError(result)) {

  // result is of type SchemaError

} else {

  // result is of type UserSchema

}

Develop this library

Install dependencies

yarn

Develop: Watch files; Recompile, type check and test on changes

yarn dev

Build

yarn build

Publish to NPM

npm run release

Readme

Keywords

none

Package Sidebar

Install

npm i tysch

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

28 kB

Total Files

6

Last publish

Collaborators

  • eliot