Skip to content

Commit ad34cfd

Browse files
authored
feat(tests): add test for kdl-schema.kdl (#30)
1 parent 364ea61 commit ad34cfd

File tree

1 file changed

+373
-0
lines changed

1 file changed

+373
-0
lines changed

Diff for: examples/kdl-schema.kdl

+373
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,373 @@
1+
document {
2+
info {
3+
title "KDL Schema" lang="en"
4+
description "KDL Schema KDL schema in KDL" lang="en"
5+
author "Kat Marchán" {
6+
link "https://github.com/zkat" rel="self"
7+
}
8+
contributor "Lars Willighagen" {
9+
link "https://github.com/larsgw" rel="self"
10+
}
11+
link "https://github.com/zkat/kdl" rel="documentation"
12+
license "Creative Commons Attribution-ShareAlike 4.0 International License" spdx="CC-BY-SA-4.0" {
13+
link "https://creativecommons.org/licenses/by-sa/4.0/" lang="en"
14+
}
15+
published "2021-08-31"
16+
modified "2021-09-01"
17+
}
18+
node "document" {
19+
min 1
20+
max 1
21+
children id="node-children" {
22+
node "node-names" id="node-names-node" description="Validations to apply specifically to arbitrary node names" {
23+
children ref=r#"[id="validations"]"#
24+
}
25+
node "other-nodes-allowed" id="other-nodes-allowed-node" description="Whether to allow child nodes other than the ones explicitly listed. Defaults to 'false'." {
26+
max 1
27+
value {
28+
min 1
29+
max 1
30+
type "boolean"
31+
}
32+
}
33+
node "tag-names" description="Validations to apply specifically to arbitrary type tag names" {
34+
children ref=r#"[id="validations"]"#
35+
}
36+
node "other-tags-allowed" description="Whether to allow child node tags other than the ones explicitly listed. Defaults to 'false'." {
37+
max 1
38+
value {
39+
min 1
40+
max 1
41+
type "boolean"
42+
}
43+
}
44+
node "info" description="A child node that describes the schema itself." {
45+
children {
46+
node "title" description="The title of the schema or the format it describes" {
47+
value description="The title text" {
48+
type "string"
49+
min 1
50+
max 1
51+
}
52+
prop "lang" id="info-lang" description="The language of the text" {
53+
type "string"
54+
}
55+
}
56+
node "description" description="A description of the schema or the format it describes" {
57+
value description="The description text" {
58+
type "string"
59+
min 1
60+
max 1
61+
}
62+
prop ref=r#"[id="info-lang"]"#
63+
}
64+
node "author" description="Author of the schema" {
65+
value id="info-person-name" description="Person name" {
66+
type "string"
67+
min 1
68+
max 1
69+
}
70+
prop "orcid" id="info-orcid" description="The ORCID of the person" {
71+
type "string"
72+
pattern r"\d{4}-\d{4}-\d{4}-\d{4}"
73+
}
74+
children {
75+
node ref=r#"[id="info-link"]"#
76+
}
77+
}
78+
node "contributor" description="Contributor to the schema" {
79+
value ref=r#"[id="info-person-name"]"#
80+
prop ref=r#"[id="info-orcid"]"#
81+
}
82+
node "link" id="info-link" description="Links to itself, and to sources describing it" {
83+
value description="A URL that the link points to" {
84+
type "string"
85+
format "url" "irl"
86+
min 1
87+
max 1
88+
}
89+
prop "rel" description="The relation between the current entity and the URL" {
90+
type "string"
91+
enum "self" "documentation"
92+
}
93+
prop ref=r#"[id="info-lang"]"#
94+
}
95+
node "license" description="The license(s) that the schema is licensed under" {
96+
value description="Name of the used license" {
97+
type "string"
98+
min 1
99+
max 1
100+
}
101+
prop "spdx" description="An SPDX license identifier" {
102+
type "string"
103+
}
104+
children {
105+
node ref=r#"[id="info-link"]"#
106+
}
107+
}
108+
node "published" description="When the schema was published" {
109+
value description="Publication date" {
110+
type "string"
111+
format "date"
112+
min 1
113+
max 1
114+
}
115+
prop "time" id="info-time" description="A time to accompany the date" {
116+
type "string"
117+
format "time"
118+
}
119+
}
120+
node "modified" description="When the schema was last modified" {
121+
value description="Modification date" {
122+
type "string"
123+
format "date"
124+
min 1
125+
max 1
126+
}
127+
prop ref=r#"[id="info-time"]"#
128+
}
129+
node "version" description="The version number of this version of the schema" {
130+
value description="Semver version number" {
131+
type "string"
132+
pattern r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
133+
min 1
134+
max 1
135+
}
136+
}
137+
}
138+
}
139+
node "tag" id="tag-node" description="A tag belonging to a child node of `document` or another node." {
140+
value description="The name of the tag. If a tag name is not supplied, the node rules apply to _all_ nodes belonging to the parent." {
141+
type "string"
142+
max 1
143+
}
144+
prop "description" description="A description of this node's purpose." {
145+
type "string"
146+
}
147+
prop "id" description="A globally-unique ID for this node." {
148+
type "string"
149+
}
150+
prop "ref" description="A globally unique reference to another node." {
151+
type "string"
152+
format "kdl-query"
153+
}
154+
children {
155+
node ref=r#"[id="node-names-node"]"#
156+
node ref=r#"[id="other-nodes-allowed-node"]"#
157+
node ref=r#"[id="node-node"]"#
158+
}
159+
}
160+
node "node" id="node-node" description="A child node belonging either to `document` or to another `node`. Nodes may be anonymous." {
161+
value description="The name of the node. If a node name is not supplied, the node rules apply to _all_ nodes belonging to the parent." {
162+
type "string"
163+
max 1
164+
}
165+
prop "description" description="A description of this node's purpose." {
166+
type "string"
167+
}
168+
prop "id" description="A globally-unique ID for this node." {
169+
type "string"
170+
}
171+
prop "ref" description="A globally unique reference to another node." {
172+
type "string"
173+
format "kdl-query"
174+
}
175+
children {
176+
node "prop-names" description="Validations to apply specifically to arbitrary property names" {
177+
children ref=r#"[id="validations"]"#
178+
}
179+
node "other-props-allowed" description="Whether to allow properties other than the ones explicitly listed. Defaults to 'false'." {
180+
max 1
181+
value {
182+
min 1
183+
max 1
184+
type "boolean"
185+
}
186+
}
187+
node "min" description="minimum number of instances of this node in its parent's children." {
188+
max 1
189+
value {
190+
min 1
191+
max 1
192+
type "number"
193+
}
194+
}
195+
node "max" description="maximum number of instances of this node in its parent's children." {
196+
max 1
197+
value {
198+
min 1
199+
max 1
200+
type "number"
201+
}
202+
}
203+
node ref=r#"[id="value-tag-node"]"#
204+
node "prop" id="prop-node" description="A node property key/value pair." {
205+
value description="The property key." {
206+
type "string"
207+
}
208+
prop "id" description="A globally-unique ID of this property." {
209+
type "string"
210+
}
211+
prop "ref" description="A globally unique reference to another property node." {
212+
type "string"
213+
format "kdl-query"
214+
}
215+
prop "description" description="A description of this property's purpose." {
216+
type "string"
217+
}
218+
children description="Property-specific validations." {
219+
node "required" description="Whether this property is required if its parent is present." {
220+
max 1
221+
value {
222+
min 1
223+
max 1
224+
type "boolean"
225+
}
226+
}
227+
}
228+
children id="validations" description="General value validations." {
229+
node "tag" id="value-tag-node" description="The tags associated with this value" {
230+
max 1
231+
children ref=r#"[id="validations"]"#
232+
}
233+
node "type" description="The type for this prop's value." {
234+
max 1
235+
value {
236+
min 1
237+
type "string"
238+
}
239+
}
240+
node "enum" description="An enumeration of possible values" {
241+
max 1
242+
value description="Enumeration choices" {
243+
min 1
244+
}
245+
}
246+
node "pattern" description="PCRE (Regex) pattern or patterns to test prop values against." {
247+
value {
248+
min 1
249+
type "string"
250+
}
251+
}
252+
node "min-length" description="Minimum length of prop value, if it's a string." {
253+
max 1
254+
value {
255+
min 1
256+
type "number"
257+
}
258+
}
259+
node "max-length" description="Maximum length of prop value, if it's a string." {
260+
max 1
261+
value {
262+
min 1
263+
type "number"
264+
}
265+
}
266+
node "format" description="Intended data format." {
267+
max 1
268+
value {
269+
min 1
270+
type "string"
271+
// https://json-schema.org/understanding-json-schema/reference/string.html#format
272+
enum "date-time" "date" "time" "duration" "decimal" "currency" "country-2" "country-3" "country-subdivision" "email" "idn-email" "hostname" "idn-hostname" "ipv4" "ipv6" "url" "url-reference" "irl" "irl-reference" "url-template" "regex" "uuid" "kdl-query" "i8" "i16" "i32" "i64" "u8" "u16" "u32" "u64" "isize" "usize" "f32" "f64" "decimal64" "decimal128"
273+
}
274+
}
275+
node "%" description="Only used for numeric values. Constrains them to be multiples of the given number(s)" {
276+
max 1
277+
value {
278+
min 1
279+
type "number"
280+
}
281+
}
282+
node ">" description="Only used for numeric values. Constrains them to be greater than the given number(s)" {
283+
max 1
284+
value {
285+
min 1
286+
max 1
287+
type "number"
288+
}
289+
}
290+
node ">=" description="Only used for numeric values. Constrains them to be greater than or equal to the given number(s)" {
291+
max 1
292+
value {
293+
min 1
294+
max 1
295+
type "number"
296+
}
297+
}
298+
node "<" description="Only used for numeric values. Constrains them to be less than the given number(s)" {
299+
max 1
300+
value {
301+
min 1
302+
max 1
303+
type "number"
304+
}
305+
}
306+
node "<=" description="Only used for numeric values. Constrains them to be less than or equal to the given number(s)" {
307+
max 1
308+
value {
309+
min 1
310+
max 1
311+
type "number"
312+
}
313+
}
314+
}
315+
}
316+
node "value" id="value-node" description="one or more direct node values" {
317+
prop "id" description="A globally-unique ID of this value." {
318+
type "string"
319+
}
320+
prop "ref" description="A globally unique reference to another value node." {
321+
type "string"
322+
format "kdl-query"
323+
}
324+
prop "description" description="A description of this property's purpose." {
325+
type "string"
326+
}
327+
children ref=r#"[id="validations"]"#
328+
children description="Node value-specific validations" {
329+
node "min" description="minimum number of values for this node." {
330+
max 1
331+
value {
332+
min 1
333+
max 1
334+
type "number"
335+
}
336+
}
337+
node "max" description="maximum number of values for this node." {
338+
max 1
339+
value {
340+
min 1
341+
max 1
342+
type "number"
343+
}
344+
}
345+
}
346+
}
347+
node "children" id="children-node" {
348+
prop "id" description="A globally-unique ID of this children node." {
349+
type "string"
350+
}
351+
prop "ref" description="A globally unique reference to another children node." {
352+
type "string"
353+
format "kdl-query"
354+
}
355+
prop "description" description="A description of this these children's purpose." {
356+
type "string"
357+
}
358+
children ref=r#"[id="node-children"]"#
359+
}
360+
}
361+
}
362+
node "definitions" description="Definitions to reference in parts of the top-level nodes" {
363+
children {
364+
node ref=r#"[id="node-node"]"#
365+
node ref=r#"[id="value-node"]"#
366+
node ref=r#"[id="prop-node"]"#
367+
node ref=r#"[id="children-node"]"#
368+
node ref=r#"[id="tag-node"]"#
369+
}
370+
}
371+
}
372+
}
373+
}

0 commit comments

Comments
 (0)