From 3a2404010f8c0fdb3a9e9940202f59b84cb2791f Mon Sep 17 00:00:00 2001 From: Gertjan van den Burg Date: Mon, 10 Jun 2019 14:34:48 +0100 Subject: Validate data according to a schema It became clear that a formal schema would make it easier to validate data. This is now added and the code is updated to work with this schema. --- app/utils/dataset_schema.json | 130 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 app/utils/dataset_schema.json (limited to 'app/utils/dataset_schema.json') diff --git a/app/utils/dataset_schema.json b/app/utils/dataset_schema.json new file mode 100644 index 0000000..2aec504 --- /dev/null +++ b/app/utils/dataset_schema.json @@ -0,0 +1,130 @@ +{ + "definitions": {}, + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "http://example.com/root.json", + "type": "object", + "title": "Dataset Schema", + "default": null, + "required": [ + "name", + "n_obs", + "n_dim", + "series" + ], + "properties": { + "name": { + "$id": "#/properties/name", + "type": "string", + "title": "The Name Schema", + "default": "", + "pattern": "^(.*)$" + }, + "n_obs": { + "$id": "#/properties/n_obs", + "type": "integer", + "title": "The N_obs Schema", + "default": 0 + }, + "n_dim": { + "$id": "#/properties/n_dim", + "type": "integer", + "title": "The N_dim Schema", + "default": 0 + }, + "demo": { + "$id": "#/properties/demo", + "type": "object", + "title": "The Demo Schema", + "properties": { + "true_CPs": { + "$id": "#/properties/demo/properties/true_CPs", + "type": "array", + "items": { + "$id": "#/properties/demo/properties/true_CPs/items", + "type": "integer", + "title": "The Items Schema", + "default": null + } + } + } + }, + "time": { + "$id": "#/properties/time", + "type": "object", + "title": "The Time Schema", + "default": null, + "required": [ + "type", + "format", + "raw" + ], + "properties": { + "type": { + "$id": "#/properties/time/properties/type", + "type": "string", + "title": "The Type Schema", + "default": "", + "pattern": "^(.*)$" + }, + "format": { + "$id": "#/properties/time/properties/format", + "type": "string", + "title": "The Format Schema", + "default": "", + "pattern": "^(.*)$" + }, + "raw": { + "$id": "#/properties/time/properties/raw", + "type": "array", + "title": "The Raw Schema", + "items": { + "$id": "#/properties/time/properties/raw/items", + "title": "The Items Schema", + "default": "" + } + } + } + }, + "series": { + "$id": "#/properties/series", + "type": "array", + "title": "The Series Schema", + "items": { + "$id": "#/properties/series/items", + "type": "object", + "title": "The Variable Schema", + "default": null, + "properties": { + "label": { + "$id": "#/properties/series/items/properties/label", + "type": "string", + "title": "The Label Schema", + "default": "", + "pattern": "^(.*)$" + }, + "type": { + "$id": "#/properties/series/items/properties/type", + "type": "string", + "title": "The Type Schema", + "default": "", + "pattern": "^(.*)$" + }, + "raw": { + "$id": "#/properties/series/items/properties/raw", + "type": "array", + "title": "The Raw Schema", + "items": { + "$id": "#/properties/series/items/properties/raw/items", + "title": "The Items Schema", + "default": 0 + } + } + }, + "required": [ + "type", + "raw" + ] + } + } + } +} -- cgit v1.2.3