-
Notifications
You must be signed in to change notification settings - Fork 11
/
sdf-validation.cddl
144 lines (126 loc) · 5.21 KB
/
sdf-validation.cddl
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
start = sdf-syntax
sdf-syntax = {
? info: sdfinfo ; This will be required in most process policies, but not a syntax error
? namespace: named<text>
? defaultNamespace: text
? sdfThing: named<thingqualities> ; Thing is a composition of objects that work together in some way
? sdfProduct: named<productqualities> ; Product is a composition of things and objects that can model a SKU-level instance of a product
? sdfObject: named<objectqualities> ; Object is a set of Properties, Actions, and Events that together perform a particular function
? sdfProperty: named<propertyqualities> ; Property represents the state of an instance of an object
? sdfAction: named<actionqualities> ; Action is a directive to invoke an application layer verb associated with an object
? sdfEvent: named<eventqualities> ; Event represents an occurence of something associated with an object
? sdfData: named<dataqualities> ; Data represents a piece of information that can be the state of a property or a parameter to an action or a signal in an event
}
sdfinfo = {
title: text
version: text
copyright: text
license: text
}
; Shortcut for a map that gives names to instances of X (has text keys and values of type X)
named<X> = { * text => X }
sdf-pointer = text ; .regexp curie-regexp -- TO DO!
pointer-list = [* sdf-pointer] ; ISSUE: no point in having an empty list, no? but used for sdfRequired in odmobject-multiple_axis_joystick.sdf.json
commonqualities = (
? description: text ; long text (no constraints)
? label: text ; short text (no constraints); default to key
? $comment: text ; source code comments only, no semantics
? sdfRef: sdf-pointer
? sdfRequired: pointer-list ; applies to qualities of properties, of data
)
; for building hierarchy
thingqualities = {
commonqualities,
? sdfObject: named<objectqualities>
? sdfThing: named<thingqualities>
}
productqualities = thingqualities ; ISSUE: get rid of sdfProduct?
; for single objects
objectqualities = {
commonqualities,
? sdfProperty: named<propertyqualities>
? sdfAction: named<actionqualities>
? sdfEvent: named<eventqualities>
? sdfData: named<dataqualities>
}
propertyqualities = dataqualities ; the definitions in sdfData are declarations in sdfProperty
parameter-list =
dataqualities .feature (["1.1", "dataqualities-as-parameter"])
actionqualities = {
commonqualities,
? sdfInputData: parameter-list ; sdfRequiredInputData applies here (a bit redundant)
? sdfOutputData: parameter-list ; sdfRequired applies here
? sdfData: named<dataqualities> ; zero or more named data type definitions that might be used in the above
}
eventqualities = {
commonqualities
? sdfOutputData: parameter-list ; sdfRequired applies here
? sdfData: named<dataqualities> ; zero or more named data type definitions that might be used in the above
}
dataqualities = { ; also propertyqualities
commonqualities,
jsonschema,
? ("unit" .feature "1.1") => text
? scaleMinimum: number
? scaleMaximum: number
? observable: bool
? readable: bool
? writable: bool
? nullable: bool
? ("sdfType" .feature "1.1") => "byte-string" / "unix-time"
? contentFormat: text
}
allowed-types = number / text / bool / null
/ [* number] / [* text] / [* bool]
/ {* text => any}
compound-type = (
"type" => ("object" .feature "1.1"),
? required: [+text],
? properties: named<dataqualities>,
)
choice-type = (
("sdfChoice" .feature "1.1") => named<dataqualities>
)
jsonschema = (
? (("type" => "number" / "string" / "boolean" / "integer" / "array")
// compound-type
// choice-type
)
? "enum" => [+ text] ; limited to text strings in SDF 1.1
? const: allowed-types ; should validate against type
? default: allowed-types ; should validate against type
; number/integer constraints
? minimum: number
? maximum: number
? exclusiveMinimum: bool / number ; jso draft 4/7
? exclusiveMaximum: bool / number ; jso draft 4/7
? multipleOf: number ; ISSUE: Do we need this?
; text string constraints
? minLength: number
? maxLength: number
? pattern: text ; regexp
? format: "date-time" / "date" / "time"
/ "uri" / "uri-reference" / "uuid"
; array constraints
? minItems: number
? maxItems: number
? uniqueItems: bool
? items: { ;;; ultimately, this will be mostly recursive, but, for now
;;; let's find out what we actually need
? sdfRef: sdf-pointer ; import limited to the subset that we allow here...
? description: text ; long text (no constraints)
? $comment: text ; source code comments only, no semantics
; commonqualities, ; -- ISSUE: should leave this out for non-complex data types, but need the above three
? ((type: "number" / "string" / "boolean" / "integer") ; no "array"
// compound-type
// choice-type ; do we really need arrays of choices?
)
; jso subset
? minimum: number
? maximum: number
? "enum" => [+ text] ; limited to text strings in SDF 1.1
? format: text
? minLength: number
? maxLength: number
}
)