Skip to content

Commit 0ae6e50

Browse files
Change: enhance definition schema with new type and colorAttribute validations
1 parent 8dbddcf commit 0ae6e50

File tree

1 file changed

+63
-8
lines changed

1 file changed

+63
-8
lines changed

src/schema/v1/definition.json

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"name": {
1313
"type": "string",
1414
"enum": [
15-
"#text",
1615
"circle",
1716
"clipPath",
1817
"defs",
@@ -71,6 +70,15 @@
7170
"view"
7271
]
7372
},
73+
"type": {
74+
"type": "string",
75+
"enum": [
76+
"element",
77+
"text",
78+
"component",
79+
"variable"
80+
]
81+
},
7482
"value": {
7583
"type": "string"
7684
},
@@ -86,6 +94,41 @@
8694
},
8795
"required": ["name"]
8896
},
97+
"colorAttribute": {
98+
"anyOf": [
99+
{
100+
"type": "string",
101+
"pattern": "^#([a-fA-F0-9]{3}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$"
102+
},
103+
{
104+
"type": "string",
105+
"pattern": "^rgba?\\(\\s*\\d+\\s*,\\s*\\d+\\s*,\\s*\\d+\\s*(,\\s*[0-1](\\.\\d+)?\\s*)?\\)$"
106+
},
107+
{
108+
"type": "string",
109+
"pattern": "^hsla?\\(\\s*\\d+\\s*,\\s*\\d+%\\s*,\\s*\\d+%\\s*(,\\s*[0-1](\\.\\d+)?\\s*)?\\)$"
110+
},
111+
{
112+
"type": "string",
113+
"pattern": "^hsba?\\(\\s*\\d+\\s*,\\s*\\d+%\\s*,\\s*\\d+%\\s*(,\\s*[0-1](\\.\\d+)?\\s*)?\\)$"
114+
},
115+
{
116+
"type": "object",
117+
"properties": {
118+
"type": {
119+
"type": "string",
120+
"enum": [
121+
"color"
122+
]
123+
},
124+
"value": {
125+
"type": "string"
126+
}
127+
},
128+
"required": ["type", "value"]
129+
}
130+
]
131+
},
89132
"attributes": {
90133
"type": "object",
91134
"properties": {
@@ -99,7 +142,9 @@
99142
"clipPathUnits": { "type": "string" },
100143
"clip-path": { "type": "string" },
101144
"clip-rule": { "type": "string" },
102-
"color": { "type": "string" },
145+
"color": {
146+
"$ref": "#/$defs/colorAttribute"
147+
},
103148
"color-interpolation": { "type": "string" },
104149
"color-interpolation-filters": { "type": "string" },
105150
"crossorigin": { "type": "string" },
@@ -116,12 +161,16 @@
116161
"edgeMode": { "type": "string" },
117162
"elevation": { "type": "string" },
118163
"exponent": { "type": "string" },
119-
"fill": { "type": "string" },
164+
"fill": {
165+
"$ref": "#/$defs/colorAttribute"
166+
},
120167
"fill-opacity": { "type": "string" },
121168
"fill-rule": { "type": "string" },
122169
"filter": { "type": "string" },
123170
"filterUnits": { "type": "string" },
124-
"flood-color": { "type": "string" },
171+
"flood-color": {
172+
"$ref": "#/$defs/colorAttribute"
173+
},
125174
"flood-opacity": { "type": "string" },
126175
"font-family": { "type": "string" },
127176
"font-size": { "type": "string" },
@@ -142,7 +191,7 @@
142191
},
143192
{
144193
"type": "string",
145-
"pattern": "^data:img/(png|gif|jpg|jpeg|webp|avif);base64,[a-zA-Z0-9+/=]+$"
194+
"pattern": "^data:image/(png|gif|jpg|jpeg|webp|avif);base64,[a-zA-Z0-9+/=]+$"
146195
}
147196
]
148197
},
@@ -160,7 +209,9 @@
160209
"lang": { "type": "string" },
161210
"lengthAdjust": { "type": "string" },
162211
"letter-spacing": { "type": "string" },
163-
"lighting-color": { "type": "string" },
212+
"lighting-color": {
213+
"$ref": "#/$defs/colorAttribute"
214+
},
164215
"marker-end": { "type": "string" },
165216
"marker-mid": { "type": "string" },
166217
"marker-start": { "type": "string" },
@@ -207,9 +258,13 @@
207258
"startOffset": { "type": "string" },
208259
"stdDeviation": { "type": "string" },
209260
"stitchTiles": { "type": "string" },
210-
"stop-color": { "type": "string" },
261+
"stop-color": {
262+
"$ref": "#/$defs/colorAttribute"
263+
},
211264
"stop-opacity": { "type": "string" },
212-
"stroke": { "type": "string" },
265+
"stroke": {
266+
"$ref": "#/$defs/colorAttribute"
267+
},
213268
"stroke-dasharray": { "type": "string" },
214269
"stroke-dashoffset": { "type": "string" },
215270
"stroke-linecap": { "type": "string" },

0 commit comments

Comments
 (0)