tysch
v1.0.1
Published
Typed schema with run-time validation
Downloads
2
Readme
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