release/0.0.3 #8

Merged
root merged 5 commits from release/0.0.3 into master 2020-06-10 14:21:12 +00:00
2 changed files with 22 additions and 5 deletions
Showing only changes of commit 464e42ba1c - Show all commits

View File

@ -4,11 +4,11 @@ const validator = {}
module.exports = validator
validator.Base = types.Base
validator.string = () => new types.StringType()
validator.number = () => new types.NumberType()
validator.boolean = () => new types.BooleanType()
validator.array = () => new types.ArrayType()
validator.object = () => new types.ObjectType()
validator.string = (...args) => new types.StringType(...args)
validator.number = (...args) => new types.NumberType(...args)
validator.boolean = (...args) => new types.BooleanType(...args)
validator.array = (...args) => new types.ArrayType(...args)
validator.object = (...args) => new types.ObjectType(...args)
/**
* validate

View File

@ -23,4 +23,21 @@ describe('test validator validate', () => {
expect(() => validator.validate(data, schema)).toThrow()
})
test('validate test 3', () => {
const data = {
str: '123',
strWithPattern: 'asd',
objWithChild: {
name: 'asd'
}
}
const schema = {
str: validator.string().required(),
strWithPattern: validator.string().pattern(/^asd$/).required(),
objWithChild: validator.object({ name: validator.string().required() }).required()
}
validator.validate(data, schema)
})
})