Skip to content

Commit b56bf05

Browse files
committed
Updated object and geometry data types #4 #5
### Added - `patternProperties` for the `object` data type - `geometryTypes` for the `geometry` data type ### Changed - Data type `object` requires any of `properties`, `patternProperties` or `additionalProperties` instead of requiring always `properties`
1 parent b16e1ec commit b56bf05

File tree

4 files changed

+79
-12
lines changed

4 files changed

+79
-12
lines changed

.github/workflows/validate.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ jobs:
1111
node-version: "lts/*"
1212
- uses: actions/checkout@v4
1313
- run: npm install -g ajv-cli
14-
- run: ajv compile -s schema/schema.json --spec=draft2020 --validate-formats=false --strict=true
14+
- run: ajv compile -s schema/schema.json --spec=draft2020 --validate-formats=false --strict=true --strict-required=false

CHANGELOG.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
99

1010
### Added
1111

12-
- ...
12+
- `patternProperties` for the `object` data type
13+
- `geometryTypes` for the `geometry` data type
1314

1415
### Changed
1516

16-
- ...
17+
- Data type `object` requires any of `properties`, `patternProperties` or `additionalProperties` instead of requiring always `properties`
1718

1819
### Deprecated
1920

README.md

+19-8
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,49 @@ At the top-level, you can also indicate the schema language and version:
2020

2121
- `$schema`: The schema identifier, see above.
2222

23-
Additionally, the following validation vocabulary is defined by JSON Schema:
23+
Additionally, the following validation vocabulary per data type is defined by JSON Schema.
2424

25-
For strings:
25+
In principle any keywords available in JSON Schema 2020-12 can be used,
26+
but it is likely unsupported by the fiboa tooling.
27+
28+
### String data type
2629

2730
- `format` (values: `email`, `idn-email`, `iri`, `uri`, `uuid`)
2831
- `pattern`
2932
- `minLength`
3033
- `maxLength`
3134
- `enum`
3235

33-
For numerical data types:
36+
### Numerical data type
3437

3538
- `minimum`
3639
- `maximum`
3740
- `exclusiveMinimum`
3841
- `exclusiveMaximum`
3942
- `enum` (for integer data types only)
4043

41-
For arrays:
44+
### Array data type
4245

4346
- `items` (required, object only, sub-schema must be compliant to fiboa Schema)
4447
- `minItems`
4548
- `maxItems`
4649
- `uniqueItems`
4750

48-
For objects:
51+
### Object data type
4952

5053
- `required`
51-
- `properties` (required, sub-schemas must be compliant to fiboa Schema)
54+
- `properties` (sub-schemas must be compliant to fiboa Schema)
5255
- `additionalProperties`
5356
(Note: In objects additional properties are disallowed by default, i.e. the default value is `false`.
5457
In JSON Schema the default value is `true`.)
58+
- `patternProperties`
59+
(Note: In objects additional properties are disallowed by default, i.e. the default value is `false`.
60+
In JSON Schema the default value is `true`.)
5561

56-
In principle any keywords available in JSON Schema 2020-12 can be used,
57-
but it is likely unsupported by the fiboa tooling.
62+
Either `properties`, `additionalProperties` or `patternProperties` must be provided.
63+
64+
### Geometry data type
65+
66+
- `geometryTypes` (not part of JSON Schema):
67+
A list of allowed geometry types.
68+
Any of: `Point`, `MultiPoint`, `LineString`, `MultiLineString`, `Polygon`, `MultiPolygon`

schema/schema.json

+56-1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@
7575
},
7676
{
7777
"$ref": "#/$defs/object"
78+
},
79+
{
80+
"$ref": "#/$defs/geometry"
7881
}
7982
]
8083
},
@@ -91,7 +94,17 @@
9194
},
9295
"then": {
9396
"type": "object",
94-
"required": ["properties"],
97+
"anyOf": [
98+
{
99+
"required": ["properties"]
100+
},
101+
{
102+
"required": ["additionalProperties"]
103+
},
104+
{
105+
"required": ["patternProperties"]
106+
}
107+
],
95108
"properties": {
96109
"required": {
97110
"type": "array",
@@ -105,6 +118,17 @@
105118
"$ref": "#/$defs/schema"
106119
}
107120
},
121+
"patternProperties": {
122+
"type": "object",
123+
"additionalProperties": {
124+
"$ref": "#/$defs/schema"
125+
},
126+
"propertyNames": {
127+
"type": "string",
128+
"format": "regex"
129+
},
130+
"default": {}
131+
},
108132
"additionalProperties": {
109133
"oneOf": [
110134
{
@@ -247,6 +271,37 @@
247271
]
248272
}
249273
},
274+
"geometry": {
275+
"if": {
276+
"type": "object",
277+
"required": ["type"],
278+
"properties": {
279+
"type": {
280+
"type": "string",
281+
"const": "geometry"
282+
}
283+
}
284+
},
285+
"then": {
286+
"type": "object",
287+
"properties": {
288+
"geometryTypes": {
289+
"type": "array",
290+
"items": {
291+
"type": "string",
292+
"enum": [
293+
"Point",
294+
"LineString",
295+
"Polygon",
296+
"MultiPoint",
297+
"MultiLineString",
298+
"MultiPolygon"
299+
]
300+
}
301+
}
302+
}
303+
}
304+
},
250305
"_numerical": {
251306
"type": "object",
252307
"properties": {

0 commit comments

Comments
 (0)