1.0.5 • Published 5 years ago

tidy-json-schema v1.0.5

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

tidy-json-schema

define and validate json schema

Installation

$ npm install tidy-json-schema --save

Usage

// for typescript

import { isErrors, tjs } from 'tidy-json-schema'

let schema = tjs.obj({
    age: tjs.int().opt(),
    name: tjs.obj({
        first: tjs.str(),
        mid: tjs.str().opt(),
        last: tjs.str(),
    }),
    friends: tjs.arr(tjs.str()).opt()
})

let result = schema.validate({})
if (isErrors(result)) {
    // result if ValidateError[]
    console.log('validate errors:', result)
} else if (result !== undefined) {
    console.log('convert to new value:', result.newValue)
} else {
    console.log('validate success')
}
1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago