Skip to content

Commit 2df6bcd

Browse files
authored
Draft 2 to 3, rules on optional, requires keyword (#43)
1 parent 66b5302 commit 2df6bcd

7 files changed

+134
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"vocabulary": "core",
3+
"condition": [
4+
{ "operation": "has-key", "path": [], "value": "properties" },
5+
{ "operation": "has-key", "path": [ "properties", {} ], "value": "optional" },
6+
{ "operation": "equals", "path": [ "properties", {}, "optional" ], "value": true }
7+
],
8+
"transform": [
9+
{ "operation": "remove", "path": [ "properties", {}, "optional" ] }
10+
]
11+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"vocabulary": "core",
3+
"condition": [
4+
{ "operation": "has-key", "path": [], "value": "properties" },
5+
{ "operation": "has-key", "path": [ "properties", {} ], "value": "optional" },
6+
{ "operation": "equals", "path": [ "properties", {}, "optional" ], "value": false },
7+
{ "operation": "has-key", "path": [ "properties", {} ], "value": "required" }
8+
],
9+
"transform": [
10+
{ "operation": "prefix-until-unique", "path": [ "properties", {}, "required" ], "value": "x-" }
11+
]
12+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"vocabulary": "core",
3+
"condition": [
4+
{ "operation": "has-key", "path": [], "value": "properties" },
5+
{ "operation": "has-key", "path": [ "properties", {} ], "value": "optional" },
6+
{ "operation": "equals", "path": [ "properties", {}, "optional" ], "value": false },
7+
{ "operation": "not-has-key", "path": [ "properties", {} ], "value": "required" }
8+
],
9+
"transform": [
10+
{ "operation": "move", "to": [ "properties", {}, "required" ], "from": [ "properties", {}, "optional" ] },
11+
{ "operation": "replace", "path": [ "properties", {}, "required" ], "value": true }
12+
]
13+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"vocabulary": "core",
3+
"condition": [
4+
{ "operation": "has-key", "path": [], "value": "properties" },
5+
{ "operation": "has-key", "path": [ "properties", {} ], "value": "requires" }
6+
],
7+
"transform": [
8+
{ "operation": "add", "path": [ "dependencies" ], "value": {} }
9+
]
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"vocabulary": "core",
3+
"condition": [
4+
{ "operation": "has-key", "path": [], "value": "properties" },
5+
{ "operation": "has-key", "path": [ "properties", {} ], "value": "requires" }
6+
],
7+
"transform": [
8+
{ "operation": "move", "to": [ "dependencies", {} ], "from": [ "properties", {}, "requires" ] }
9+
]
10+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
[
2+
{
3+
"title": "properties has children who have optional:false and required is already present",
4+
"from": {
5+
"properties": {
6+
"foo": {
7+
"required": "string",
8+
"optional": false
9+
}
10+
}
11+
},
12+
"to": {
13+
"properties": {
14+
"foo": {
15+
"x-required": "string",
16+
"required": true
17+
}
18+
}
19+
}
20+
},
21+
{
22+
"title": "properties has children who have optional:false",
23+
"from": {
24+
"properties": {
25+
"foo": {
26+
"optional": false
27+
}
28+
}
29+
},
30+
"to": {
31+
"properties": {
32+
"foo": {
33+
"required": true
34+
}
35+
}
36+
}
37+
},
38+
{
39+
"title": "properties has children who have optional:true",
40+
"from": {
41+
"properties": {
42+
"foo": {
43+
"optional": true
44+
}
45+
}
46+
},
47+
"to": {
48+
"properties": {
49+
"foo": {}
50+
}
51+
}
52+
}
53+
]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[
2+
{
3+
"title": "properties has children who have `requires` keyword",
4+
"from": {
5+
"properties": {
6+
"foo": {
7+
"requires": "bar"
8+
},
9+
"bar": {
10+
"requires": { "type": "string"}
11+
}
12+
}
13+
},
14+
"to": {
15+
"properties": {
16+
"foo": {},
17+
"bar": {}
18+
},
19+
"dependencies": {
20+
"foo": "bar",
21+
"bar": { "type": "string"}
22+
}
23+
}
24+
}
25+
]

0 commit comments

Comments
 (0)