1.0.1 • Published 4 years ago

tysch v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

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