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