Compare commits
No commits in common. "564578c1605840af1d8a858ac8f1ab8d5f57798c" and "e399cb0e30bf448e0766759180a645fdd399e151" have entirely different histories.
564578c160
...
e399cb0e30
@ -1,9 +1,5 @@
|
||||
# ChangeLog
|
||||
|
||||
## 2020-06-10 (0.0.3)
|
||||
|
||||
- add types init value
|
||||
|
||||
## 2020-06-10 (0.0.2)
|
||||
|
||||
- add string type pattern check function
|
||||
|
10
index.js
10
index.js
@ -4,11 +4,11 @@ const validator = {}
|
||||
module.exports = validator
|
||||
|
||||
validator.Base = types.Base
|
||||
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)
|
||||
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()
|
||||
|
||||
/**
|
||||
* validate
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mtfos-validator",
|
||||
"version": "0.0.3",
|
||||
"version": "0.0.2",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
@ -24,7 +24,5 @@ describe('test validate type schema object', () => {
|
||||
}).required()
|
||||
|
||||
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()
|
||||
})
|
||||
|
||||
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