Compare commits

...

6 Commits

Author SHA1 Message Date
Jay
564578c160 Merge pull request 'release/0.0.3' (#8) from release/0.0.3 into master
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2020-06-10 14:21:12 +00:00
Jay
70cc973927 bump version and edit changelog
All checks were successful
continuous-integration/drone/push Build is passing
2020-06-10 14:19:00 +00:00
Jay
81bde1577c Merge pull request 'feature/modify-types-init-value' (#7) from feature/modify-types-init-value into develop
All checks were successful
continuous-integration/drone/push Build is passing
2020-06-10 14:17:29 +00:00
Jay
cdbecea36d [chore] add test set
All checks were successful
continuous-integration/drone/push Build is passing
2020-06-10 14:15:02 +00:00
Jay
464e42ba1c [fix] add types init values 2020-06-10 14:13:34 +00:00
Jay
a6d39d487a Merge pull request 'bump version and modify changelog' (#6) from release/0.0.2 into develop
All checks were successful
continuous-integration/drone/push Build is passing
2020-06-10 13:39:21 +00:00
5 changed files with 29 additions and 6 deletions

View File

@ -1,5 +1,9 @@
# ChangeLog
## 2020-06-10 (0.0.3)
- add types init value
## 2020-06-10 (0.0.2)
- add string type pattern check function

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

@ -1,6 +1,6 @@
{
"name": "mtfos-validator",
"version": "0.0.2",
"version": "0.0.3",
"description": "",
"main": "index.js",
"scripts": {

View File

@ -24,5 +24,7 @@ describe('test validate type schema object', () => {
}).required()
throwFunc(obj.validate({ name: 'asd' }))
expect(throwFunc(obj.validate({ name: 123 }))).toThrow()
})
})

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)
})
})