1.0.1 • Published 6 years ago
tysch v1.0.1
tysch
Typed schema with run-time validation
Install
yarn add tyschUse
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
yarnDevelop: Watch files; Recompile, type check and test on changes
yarn devBuild
yarn buildPublish to NPM
npm run release