File tree Expand file tree Collapse file tree 7 files changed +101
-8
lines changed Expand file tree Collapse file tree 7 files changed +101
-8
lines changed Original file line number Diff line number Diff line change 23
23
- run : yarn lint
24
24
- run : git submodule update --init --recursive
25
25
- run : yarn run test
26
+ types :
27
+ name : ' Test types'
28
+ runs-on : ubuntu-latest
29
+ defaults :
30
+ run :
31
+ working-directory : test/types
32
+ steps :
33
+ - uses : actions/checkout@v4
34
+ - uses : actions/setup-node@v4
35
+ with :
36
+ node-version : 20
37
+ - run : yarn
38
+ - run : yarn test
Original file line number Diff line number Diff line change @@ -15,8 +15,8 @@ type Schema =
15
15
$id ?: string
16
16
$anchor ?: string
17
17
$ref ?: string
18
- definitions ?: { [ id : string ] : Schema }
19
- $defs ?: { [ id : string ] : Schema }
18
+ definitions ?: Partial < { [ id : string ] : Schema } >
19
+ $defs ?: Partial < { [ id : string ] : Schema } >
20
20
$recursiveRef ?: string
21
21
$recursiveAnchor ?: boolean
22
22
// generic
@@ -61,15 +61,15 @@ type Schema =
61
61
contentMediaType ?: string
62
62
contentSchema ?: Schema
63
63
// objects
64
- properties ?: { [ id : string ] : Schema }
64
+ properties ?: Partial < { [ id : string ] : Schema } >
65
65
maxProperties ?: number
66
66
minProperties ?: number
67
67
additionalProperties ?: Schema
68
- patternProperties ?: { [ pattern : string ] : Schema }
68
+ patternProperties ?: Partial < { [ pattern : string ] : Schema } >
69
69
propertyNames ?: Schema
70
- dependencies ?: { [ id : string ] : Array < string > | Schema }
71
- dependentRequired ?: { [ id : string ] : Array < string > }
72
- dependentSchemas ?: { [ id : string ] : Schema }
70
+ dependencies ?: Partial < { [ id : string ] : Array < string > | Schema } >
71
+ dependentRequired ?: Partial < { [ id : string ] : Array < string > } >
72
+ dependentSchemas ?: Partial < { [ id : string ] : Schema } >
73
73
// see-through
74
74
unevaluatedProperties ?: Schema
75
75
unevaluatedItems ?: Schema
Original file line number Diff line number Diff line change 36
36
"test" : " npm run test:raw | tap-spec" ,
37
37
"test:raw" : " npm run test:normal && npm run test:module" ,
38
38
"test:module" : " tape -r ./test/tools/test-module.js test/*.js test/regressions/*.js" ,
39
- "test:normal" : " tape test/*.js test/regressions/*.js"
39
+ "test:normal" : " tape test/*.js test/regressions/*.js" ,
40
+ "test:types" : " yarn --cwd test/types test"
40
41
},
41
42
"dependencies" : {},
42
43
"devDependencies" : {
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " type-tests" ,
3
+ "private" : true ,
4
+ "devDependencies" : {
5
+ "@types/node" : " ^20.11.16" ,
6
+ "typescript" : " ^5.3.3"
7
+ },
8
+ "scripts" : {
9
+ "test" : " tsc --noEmit"
10
+ }
11
+ }
Original file line number Diff line number Diff line change
1
+ import { validator } from '../../../index'
2
+
3
+ const schema = {
4
+ type : 'object' ,
5
+ allOf : [
6
+ {
7
+ if : {
8
+ properties : {
9
+ propertyA : {
10
+ const : 1 ,
11
+ } ,
12
+ } ,
13
+ } ,
14
+ then : {
15
+ properties : {
16
+ propertyB : {
17
+ const : null ,
18
+ } ,
19
+ } ,
20
+ } ,
21
+ } ,
22
+ {
23
+ if : {
24
+ properties : {
25
+ propertyA : {
26
+ const : 2 ,
27
+ } ,
28
+ } ,
29
+ } ,
30
+ then : {
31
+ properties : {
32
+ propertyC : {
33
+ const : null ,
34
+ } ,
35
+ } ,
36
+ } ,
37
+ } ,
38
+ ] ,
39
+ }
40
+
41
+ const myValidator = validator ( schema )
Original file line number Diff line number Diff line change
1
+ {
2
+ "compilerOptions" : {
3
+ "strict" : true ,
4
+ },
5
+ "include" : [" tests" ],
6
+ "exclude" : [" node_modules" ]
7
+ }
Original file line number Diff line number Diff line change
1
+ # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
+ # yarn lockfile v1
3
+
4
+
5
+ " @types/node@^20.11.16 " :
6
+ version "20.11.16"
7
+ resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.16.tgz#4411f79411514eb8e2926f036c86c9f0e4ec6708"
8
+ integrity sha512-gKb0enTmRCzXSSUJDq6/sPcqrfCv2mkkG6Jt/clpn5eiCbKTY+SgZUxo+p8ZKMof5dCp9vHQUAB7wOUTod22wQ==
9
+ dependencies :
10
+ undici-types "~5.26.4"
11
+
12
+ typescript@^5.3.3 :
13
+ version "5.3.3"
14
+ resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.3.3.tgz#b3ce6ba258e72e6305ba66f5c9b452aaee3ffe37"
15
+ integrity sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==
16
+
17
+ undici-types@~5.26.4 :
18
+ version "5.26.5"
19
+ resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
20
+ integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==
You can’t perform that action at this time.
0 commit comments