Skip to content

koss-lebedev/type-validate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Type-validate

Check an object against predefined schema.

Installation

Using npm:

npm i -S type-validate

Using yarn:

yarn add type-validate

Example

Sample typings definition:

const typings = {
  name: 'string',
  age: 'number',
  height: 'number?',
  isDeveloper: 'boolean',
  birthDate: 'date|number',
  address: {
    country: 'string?',
    city: 'string',
  },
  posts: [{
    title: 'string'
  }, true],
}

Supported types

  • primitive types - string, number, boolean, date, and undefined
  • optional types, defined with ?, like string?
  • union types, defined with |, like string|number
  • array types, defined as [arrayItemType, isOptional]

About

Check an object against predefined schema.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published