0.0.1 • Published 6 years ago

type-validate v0.0.1

Weekly downloads
2
License
MIT
Repository
-
Last release
6 years ago

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, and undefined
  • optional types, defined with ?
  • union types, defined with |
  • array types, defined as [arrayItemType, canArrayBeUndefined]