Compare commits
No commits in common. "81bde1577c0e0d9e543e8c2b2cd9610729eede68" and "a6d39d487aa366b6cd4752b6fbde4b5f4e0ef2e3" have entirely different histories.
81bde1577c
...
a6d39d487a
10
index.js
10
index.js
@ -4,11 +4,11 @@ const validator = {}
|
|||||||
module.exports = validator
|
module.exports = validator
|
||||||
|
|
||||||
validator.Base = types.Base
|
validator.Base = types.Base
|
||||||
validator.string = (...args) => new types.StringType(...args)
|
validator.string = () => new types.StringType()
|
||||||
validator.number = (...args) => new types.NumberType(...args)
|
validator.number = () => new types.NumberType()
|
||||||
validator.boolean = (...args) => new types.BooleanType(...args)
|
validator.boolean = () => new types.BooleanType()
|
||||||
validator.array = (...args) => new types.ArrayType(...args)
|
validator.array = () => new types.ArrayType()
|
||||||
validator.object = (...args) => new types.ObjectType(...args)
|
validator.object = () => new types.ObjectType()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* validate
|
* validate
|
||||||
|
@ -24,7 +24,5 @@ describe('test validate type schema object', () => {
|
|||||||
}).required()
|
}).required()
|
||||||
|
|
||||||
throwFunc(obj.validate({ name: 'asd' }))
|
throwFunc(obj.validate({ name: 'asd' }))
|
||||||
|
|
||||||
expect(throwFunc(obj.validate({ name: 123 }))).toThrow()
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -23,21 +23,4 @@ describe('test validator validate', () => {
|
|||||||
|
|
||||||
expect(() => validator.validate(data, schema)).toThrow()
|
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)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user