Skip to content

N-Field/schemastery

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Schemastery

Just another schema validator.

Examples

use as validator (JavaScript)

const Schema = require('schemastery')

const validate = Schema.number({ default: 10 })

validate(0)     // 0
validate(null)  // 10
validate('')    // Error

use as constructor (TypeScript)

import Schema from 'schemastery'

interface Config {
  foo?: 'red' | 'blue'
  bar: string[]
}

const Config = Schema.object({
  foo: Schema.select(['red', 'blue'], { default: 'red' }),
  bar: Schema.array(Schema.string()),
})

const config = new Config()
// config is an instance of Config
// in this case, that is, { foo: red, bar: [] }

About

Just another schema validator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 99.4%
  • JavaScript 0.6%