validator/index.js

24 lines
801 B
JavaScript
Raw Normal View History

2020-06-11 15:04:57 +00:00
const TypeBase = require('./types/base.js')
const TypeString = require('./types/string.js')
const TypeNumber = require('./types/number.js')
const TypeBoolean = require('./types/boolean.js')
const TypeArray = require('./types/array.js')
const TypeObject = require('./types/object.js')
const validate = require('./validate.js')
2020-06-03 15:49:04 +00:00
const validator = {}
module.exports = validator
2020-06-11 15:04:57 +00:00
validator.Base = TypeBase
validator.string = (...args) => new TypeString(...args)
validator.number = (...args) => new TypeNumber(...args)
validator.boolean = (...args) => new TypeBoolean(...args)
validator.array = (...args) => new TypeArray(...args)
validator.object = (...args) => new TypeObject(...args)
2020-06-03 15:49:04 +00:00
/**
* validate
* @param {Object} src
* @param {import('./type.js').Schema} schema
2020-06-03 15:49:04 +00:00
*/
validator.validate = validate