...
1-- type.json --
2{
3 "type": "object",
4 "title": "Main schema",
5
6 "properties": {
7 "fields" : {
8 "type": "object",
9 "minProperties": 3,
10 "maxProperties": 10,
11 "propertyNames": {
12 "pattern": "^\\P{Lu}"
13 }
14 },
15 "additional": {
16 "type": "object",
17 "properties": {
18 "foo": { "type": "number" },
19 "bar": { "type": "number" }
20 },
21 "additionalProperties": { "type": "string" }
22 },
23 "map": {
24 "type": "object",
25 "additionalProperties": { "type": "string" }
26 },
27 "patterns": {
28 "type": "object",
29 "properties": {
30 "foo": { "type": "number" },
31 "bar": { "type": "number" }
32 },
33 "patternProperties": {
34 "^\\P{Lu}": { "type": "string" },
35 "^\\P{Lo}": { "type": "integer" }
36 }
37 },
38 "patternsNoProps": {
39 "type": "object",
40 "patternProperties": {
41 "^\\P{Lu}": { "type": "string" },
42 "^\\P{Lo}": { "type": "integer" }
43 }
44 },
45 "complex": {
46 "type": "object",
47 "properties": {
48 "foo": { "type": "number" },
49 "bar": { "type": "number" }
50 },
51 "patternProperties": {
52 "^\\P{Lu}": { "type": "string" },
53 "^\\P{Lo}": { "type": "integer" }
54 },
55 "additionalProperties": { "type": "string" }
56 },
57 "multi": {
58 "type": [ "object", "number" ],
59 "properties": {
60 "foo": { "type": "number" },
61 "bar": { "type": "number" }
62 },
63 "maxProperties": 5,
64 "minimum": 7
65 }
66 },
67 "additionalProperties": false
68}
69
70-- out.cue --
71import "struct"
72
73// Main schema
74fields?: struct.MaxFields(10) & {
75 [=~"^\\P{Lu}"]: _
76}
77additional?: {
78 foo?: number
79 bar?: number
80 {[!~"^(foo|bar)$"]: string}
81}
82map?: [string]: string
83patterns?: {
84 foo?: number
85 bar?: number
86
87 {[=~"^\\P{Lu}" & !~"^(foo|bar)$"]: string}
88
89 {[=~"^\\P{Lo}" & !~"^(foo|bar)$"]: int}
90 ...
91}
92patternsNoProps?: {
93 {[=~"^\\P{Lu}" & !~"^()$"]: string}
94
95 {[=~"^\\P{Lo}" & !~"^()$"]: int}
96 ...
97}
98complex?: {
99 foo?: number
100 bar?: number
101
102 {[=~"^\\P{Lu}" & !~"^(foo|bar)$"]: string}
103
104 {[=~"^\\P{Lo}" & !~"^(foo|bar)$"]: int}
105 {[!~"^\\P{Lu}" & !~"^\\P{Lo}" & !~"^(foo|bar)$"]: string}
106}
107multi?: >=7 | struct.MaxFields(5) & {
108 foo?: number
109 bar?: number
110 ...
111}
View as plain text