diff --git a/behaverse/validators/nback.schema.json b/behaverse/validators/nback.schema.json index 1feb724..800c99d 100644 --- a/behaverse/validators/nback.schema.json +++ b/behaverse/validators/nback.schema.json @@ -45,6 +45,79 @@ "type": "string" } }, + "Custom_NBack_TaskStart": { + "$comment": "NBack.TaskStart custom field", + "type": "object", + "additionalProperties": false, + "properties": { + "timeline": {"type": "string"}, + "seed": {"type": "number"} + } + }, + "Custom_NBack_BlockStart": { + "$comment": "NBack.BlockStart custom field. We need to seperate Instructions blocks from Game blocks", + "type": "object", + "additionalProperties": false, + "properties": { + "id": {"type": "number"}, + "type": {"type": "string", "enum": [null, "Game", "Instructions"]} + } + }, + "Custom_NBack_BlockEnd": { + "$comment": "NBack.BlockEnd custom field.", + "type": "object", + "additionalProperties": false, + "properties": { + "id": {"type": "number"}, + "type": {"type": "string", "enum": ["Game", "Instructions"]}, + "name": {"type": "string"}, + "seed": {"type": "number"}, + "accuracy": {"type": "number"}, + "hitCount": {"type": "number", "minimum": 0}, + "missCount": {"type": "number", "minimum": 0}, + "falseAlarmCount": {"type": "number"}, + "correctRejectionCount": {"type": "number"}, + "timeOutCount": {"type": "number", "minimum": 0} + + }, + "required": ["id","type","name","seed","accuracy","hitCount","missCount", "falseAlaram", "correctRejectionCount", "timeOutCount"] + }, + "Custom_NBack_TaskEnd": { + "$comment": "NBack.TaskEnd custom field.", + "type": "object", + "additionalProperties": false, + "properties": {} + }, + "Custom_NBack_TrialEnd": { + "$comment": "NBack.TrialEnd custom field.", + "type": "object", + "additionalProperties": false, + "properties": {} + }, + "Custom_NBack_TrialStart": { + "$comment": "NBack.TrialStart custom field.", + "type": "object", + "additionalProperties": false, + "properties": { + "id": {"type": "number"}, + "seed": {"type": "number"} + } + }, + "Custom_NBack_MatchingButtonClick": { + "$comment": "NBack.MatchingButtonClick custom field.", + "type": "object", + "additionalProperties": false, + "properties": { + "isMatch": {"type": "boolean"}, + "pressDuration": {"type": "number"}, + "pressTime": {"type": "string", "format": "date-time"}, + "streamIndex": {"type": "number"}, + "responseTime": {"type": ["number", "null"]}, + "viewportPosition": { "$ref": "#/definitions/XY_Position" }, + "worldPosition": { "$ref": "#/definitions/XY_Position" } + }, + "required": ["worldPosition", "viewportPosition", "pressTime", "pressDuration", "isMatch", "streamIndex", "responseTime"] + }, "Custom":{ "type": "object", "$comment": "extract custom keys using this JQ query: '[.[] | .custom | keys | .[]] | unique | sort'", @@ -75,67 +148,15 @@ "viewportPosition": { "$ref": "#/definitions/XY_Position" }, "worldPosition": { "$ref": "#/definitions/XY_Position" } }, - "additionalProperties": true, - "anyOf": [ - { - "if": { - "properties": {"types": {"enum": ["NBack.TaskStart"]}} - }, - "then": { - "required": ["timeline", "seed"] - } - }, - { - "if": { - "properties": { - "types": {"enum": ["NBack.BlockStart"]} - } - }, - "then": { - "required": ["id", "type"] - } - }, - { - "if": { - "properties": {"types": {"enum": ["NBack.BlockEnd"]}}, - "$comment": "jq command to extract required parameters: [.[] | select(.types | .[] | contains(\"NBack.BlockEnd\")) | .custom | keys] | unique | .[][]" - }, - "then": { - "required": ["id","type","name","seed","accuracy","hitCount","missCount", "falseAlaram", "correctRejectionCount", "timeOutCount"] - } - }, - { - "if": { - "properties": {"types": {"enum": ["NBack.TaskEnd"]}} - }, - "then": { - "required": [] - } - }, - { - "if": { - "properties": {"types": {"enum": ["NBack.TrialEnd"]}} - }, - "then": { - "required": [] - } - }, - { - "if": { - "properties": {"types": {"enum": ["NBack.TrialStart"]}} - }, - "then": { - "required": ["id", "seed"] - } - }, - { - "if": { - "properties": {"types": {"enum": ["NBack.MatchingButtonClick"]}} - }, - "then": { - "required": ["worldPosition", "viewportPosition", "pressTime", "pressDuration", "isMatch", "streamIndex", "responseTime"] - } - } + "additionalProperties": false, + "oneOf": [ + { "$ref": "#/definitions/Custom_NBack_TaskStart"}, + { "$ref": "#/definitions/Custom_NBack_BlockStart"}, + { "$ref": "#/definitions/Custom_NBack_BlockEnd"}, + { "$ref": "#/definitions/Custom_NBack_TaskEnd"}, + { "$ref": "#/definitions/Custom_NBack_TrialEnd"}, + { "$ref": "#/definitions/Custom_NBack_TrialStart"}, + { "$ref": "#/definitions/Custom_NBack_MatchingButtonClick"} ] }, "XY_Position": {