type-validate
v0.0.1
Published
Library for checking objects against type schema
Downloads
2
Readme
Type-validate
Check an object against predefined schema.
Example
Sample typings definition:
{
name: 'string',
age: 'number',
height: 'number?',
isDeveloper: 'boolean',
birthDate: 'date|number',
address: {
country: 'string?',
city: 'string',
},
posts: [{
title: 'string'
}, true],
}
It supports:
- primitive types -
string
,number
,boolean
,date
, andundefined
- optional types, defined with
?
- union types, defined with
|
- array types, defined as
[arrayItemType, canArrayBeUndefined]