Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eliot-akira/tysch
Typed schema with run-time validation
https://github.com/eliot-akira/tysch
Last synced: about 1 month ago
JSON representation
Typed schema with run-time validation
- Host: GitHub
- URL: https://github.com/eliot-akira/tysch
- Owner: eliot-akira
- License: other
- Created: 2020-02-09T18:36:25.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-06-01T13:53:48.000Z (over 4 years ago)
- Last Synced: 2024-09-13T05:58:23.218Z (2 months ago)
- Language: TypeScript
- Size: 7.81 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# tysch
Typed schema with run-time validation
## Install
```sh
yarn add tysch
```## Use
```ts
import {
type as t,
Static,
validate,
isError
} from 'tysch'const userSchema = t.object({
name: t.string(),
points: t.number(),
})type UserSchema = Static
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
```sh
yarn
```Develop: Watch files; Recompile, type check and test on changes
```sh
yarn dev
```Build
```sh
yarn build
```Publish to NPM
```sh
npm run release
```