validator/index.js
Jay ca57604da8
All checks were successful
continuous-integration/drone/push Build is passing
[feat] change require types method
2020-06-11 15:04:57 +00:00

24 lines
801 B
JavaScript

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')
const validator = {}
module.exports = validator
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)
/**
* validate
* @param {Object} src
* @param {import('./type.js').Schema} schema
*/
validator.validate = validate