File tree 8 files changed +262
-201
lines changed
8 files changed +262
-201
lines changed Original file line number Diff line number Diff line change @@ -59,3 +59,4 @@ typings/
59
59
60
60
# testing file
61
61
sandbox.js
62
+ .vscode /
Original file line number Diff line number Diff line change 10
10
## ` array.continuous(comparator, limit) `
11
11
12
12
Specifies the allowed date format:
13
- - ` comparator ` - ` string ` that should check continuous or not.
13
+ - ` comparator ` - ` string ` or ` func ` that should check continuous or not.
14
14
- ` limit ` - ` integer ` or ` ref ` the value of ` comparator ` should be start. Default ` 0 `
15
15
16
16
``` js
Original file line number Diff line number Diff line change @@ -8,8 +8,10 @@ Joi extensions for extra array rules.
8
8
[ ![ Build status] ( https://ci.appveyor.com/api/projects/status/6942dw1ikdg729y2/branch/master?svg=true )] ( https://ci.appveyor.com/project/buianhthang/joi-array-extensions/branch/master )
9
9
[ ![ Dependency Status] ( https://dependencyci.com/github/buianhthang/joi-array-extensions/badge )] ( https://dependencyci.com/github/buianhthang/joi-array-extensions )
10
10
11
- # Usage
11
+ # API
12
+ See the [ API Reference] ( https://github.com/buianhthang/joi-array-extensions/blob/master/API.md ) .
12
13
14
+ # Usage
13
15
Usage is a two steps process. First, a schema is constructed using the provided types and constraints:
14
16
15
17
``` js
@@ -25,13 +27,10 @@ const schema = Joi.array().items({
25
27
# Coverage
26
28
27
29
```
28
- 9 tests complete
29
- Test duration: 59 ms
30
- Assertions count: 25 (verbosity: 2.78 )
30
+ 7 tests complete
31
+ Test duration: 56 ms
32
+ Assertions count: 40 (verbosity: 5.71 )
31
33
No global variable leaks detected
32
34
Coverage: 100.00%
33
35
Linting results: No issues
34
36
```
35
-
36
- # API
37
- See the [ API Reference] ( https://github.com/buianhthang/joi-array-extensions/blob/master/API.md ) .
Original file line number Diff line number Diff line change @@ -2,10 +2,6 @@ version: 1.0.{build}-{branch}
2
2
3
3
build : off
4
4
5
- artifacts :
6
- - path : build\**\*.tar.gz
7
- name : joi-array-extensions
8
-
9
5
environment :
10
6
matrix :
11
7
- nodejs_version : " 8"
Original file line number Diff line number Diff line change @@ -18,7 +18,10 @@ module.exports = [
18
18
return `${ params . comparator } must be an integer and started continuous from ${ params . limit } `
19
19
} ,
20
20
params : Joi . object ( ) . keys ( {
21
- comparator : Joi . string ( ) . required ( ) ,
21
+ comparator : Joi . alternatives (
22
+ Joi . string ( ) . required ( ) ,
23
+ Joi . func ( )
24
+ ) ,
22
25
limit : Joi . alternatives ( )
23
26
. try ( Joi . number ( ) . integer ( ) , Joi . func ( ) . ref ( ) )
24
27
. default ( 0 )
@@ -46,8 +49,16 @@ module.exports = [
46
49
startFrom = limit
47
50
}
48
51
52
+ let key
53
+ if ( typeof comparator === 'function' ) {
54
+ key = 'function comparator'
55
+ }
56
+ if ( typeof comparator === 'string' ) {
57
+ key = comparator
58
+ }
59
+
49
60
const localState = {
50
- key : comparator ,
61
+ key,
51
62
path : state . path . concat ( comparator ) ,
52
63
parent : state . parent ,
53
64
reference : state . reference
Original file line number Diff line number Diff line change 44
44
},
45
45
"devDependencies" : {
46
46
"eslint" : " ^4.7.2" ,
47
- "eslint-config-airbnb-base" : " ^12.0.0 " ,
47
+ "eslint-config-airbnb-base" : " ^12.0.1 " ,
48
48
"eslint-config-prettier" : " ^2.5.0" ,
49
49
"eslint-plugin-import" : " ^2.7.0" ,
50
50
"eslint-plugin-prettier" : " ^2.3.1" ,
51
51
"husky" : " ^0.14.3" ,
52
- "joi" : " ^11.0.3 " ,
52
+ "joi" : " ^11.1.1 " ,
53
53
"lab" : " ^14.3.1" ,
54
54
"lint-staged" : " ^4.2.1" ,
55
- "prettier" : " ^1.7.0 "
55
+ "prettier" : " ^1.7.2 "
56
56
}
57
57
}
You can’t perform that action at this time.
0 commit comments