15
15
package jsonschema
16
16
17
17
import (
18
+ "fmt"
19
+
18
20
"cuelang.org/go/cue"
19
21
)
20
22
@@ -44,6 +46,9 @@ var constraintMap = map[string]*constraint{}
44
46
45
47
func init () {
46
48
for _ , c := range constraints {
49
+ if _ , ok := constraintMap [c .key ]; ok {
50
+ panic (fmt .Errorf ("duplicate constraint entry for %q" , c .key ))
51
+ }
47
52
constraintMap [c .key ] = c
48
53
}
49
54
}
@@ -54,51 +59,74 @@ func init() {
54
59
const numPhases = 5
55
60
56
61
var constraints = []* constraint {
62
+ todo ("$anchor" , vfrom (VersionDraft2019_09 )),
57
63
p2d ("$comment" , constraintComment , vfrom (VersionDraft7 )),
58
64
p2 ("$defs" , constraintAddDefinitions ),
65
+ todo ("$dynamicAnchor" , vfrom (VersionDraft2020_12 )),
66
+ todo ("$dynamicRef" , vfrom (VersionDraft2020_12 )),
59
67
p1d ("$id" , constraintID , vfrom (VersionDraft6 )),
60
- p0 ("$schema" , constraintSchema ),
68
+ todo ("$recursiveAnchor" , vbetween (VersionDraft2019_09 , VersionDraft2020_12 )),
69
+ todo ("$recursiveRef" , vbetween (VersionDraft2019_09 , VersionDraft2020_12 )),
61
70
p2 ("$ref" , constraintRef ),
62
- p2 ("additionalItems" , constraintAdditionalItems ),
71
+ p0 ("$schema" , constraintSchema ),
72
+ todo ("$vocabulary" , vfrom (VersionDraft2019_09 )),
73
+ p2d ("additionalItems" , constraintAdditionalItems , vto (VersionDraft2019_09 )),
63
74
p4 ("additionalProperties" , constraintAdditionalProperties ),
64
75
p3 ("allOf" , constraintAllOf ),
65
76
p3 ("anyOf" , constraintAnyOf ),
66
77
p2d ("const" , constraintConst , vfrom (VersionDraft6 )),
67
- p1d ("minContains" , constraintMinContains , vfrom (VersionDraft2019_09 )),
68
- p1d ("maxContains" , constraintMaxContains , vfrom (VersionDraft2019_09 )),
69
78
p2d ("contains" , constraintContains , vfrom (VersionDraft6 )),
70
79
p2d ("contentEncoding" , constraintContentEncoding , vfrom (VersionDraft7 )),
71
80
p2d ("contentMediaType" , constraintContentMediaType , vfrom (VersionDraft7 )),
81
+ todo ("contentSchema" , vfrom (VersionDraft2019_09 )),
72
82
p2 ("default" , constraintDefault ),
73
83
p2 ("definitions" , constraintAddDefinitions ),
74
84
p2 ("dependencies" , constraintDependencies ),
85
+ todo ("dependentRequired" , vfrom (VersionDraft2019_09 )),
86
+ todo ("dependentSchemas" , vfrom (VersionDraft2019_09 )),
75
87
p2 ("deprecated" , constraintDeprecated ),
76
88
p2 ("description" , constraintDescription ),
89
+ todo ("else" , vfrom (VersionDraft7 )),
77
90
p2 ("enum" , constraintEnum ),
78
91
p2d ("examples" , constraintExamples , vfrom (VersionDraft6 )),
79
92
p2 ("exclusiveMaximum" , constraintExclusiveMaximum ),
80
93
p2 ("exclusiveMinimum" , constraintExclusiveMinimum ),
94
+ todo ("format" , allVersions ),
81
95
p1d ("id" , constraintID , vto (VersionDraft4 )),
96
+ todo ("if" , vfrom (VersionDraft7 )),
82
97
p2 ("items" , constraintItems ),
83
- p2 ( "minItems " , constraintMinItems ),
98
+ p1d ( "maxContains " , constraintMaxContains , vfrom ( VersionDraft2019_09 ) ),
84
99
p2 ("maxItems" , constraintMaxItems ),
85
100
p2 ("maxLength" , constraintMaxLength ),
86
101
p2 ("maxProperties" , constraintMaxProperties ),
87
102
p3 ("maximum" , constraintMaximum ),
103
+ p1d ("minContains" , constraintMinContains , vfrom (VersionDraft2019_09 )),
104
+ p2 ("minItems" , constraintMinItems ),
88
105
p2 ("minLength" , constraintMinLength ),
106
+ todo ("minProperties" , allVersions ),
89
107
p3 ("minimum" , constraintMinimum ),
90
108
p2 ("multipleOf" , constraintMultipleOf ),
91
109
p3 ("not" , constraintNot ),
92
- p3 ("oneOf" , constraintOneOf ),
93
110
p2 ("nullable" , constraintNullable ),
111
+ p3 ("oneOf" , constraintOneOf ),
94
112
p2 ("pattern" , constraintPattern ),
95
113
p3 ("patternProperties" , constraintPatternProperties ),
114
+ todo ("prefixItems" , vfrom (VersionDraft2020_12 )),
96
115
p2 ("properties" , constraintProperties ),
97
116
p2d ("propertyNames" , constraintPropertyNames , vfrom (VersionDraft6 )),
117
+ todo ("readOnly" , vfrom (VersionDraft7 )),
98
118
p3 ("required" , constraintRequired ),
119
+ todo ("then" , vfrom (VersionDraft7 )),
99
120
p2 ("title" , constraintTitle ),
100
121
p2 ("type" , constraintType ),
122
+ todo ("unevaluatedItems" , vfrom (VersionDraft2019_09 )),
123
+ todo ("unevaluatedProperties" , vfrom (VersionDraft2019_09 )),
101
124
p2 ("uniqueItems" , constraintUniqueItems ),
125
+ todo ("writeOnly" , vfrom (VersionDraft7 )),
126
+ }
127
+
128
+ func todo (name string , versions versionSet ) * constraint {
129
+ return & constraint {key : name , phase : 1 , versions : versions , fn : constraintTODO }
102
130
}
103
131
104
132
func p0 (name string , f constraintFunc ) * constraint {
0 commit comments