Missing constraints in JSON schemas

Hi all,

I just found many missing constraints and raised a ticket in JIRA Jira

  1. Values for DV_DATE, DV_TIME, DV_DATE_TIME and DV_DURATION should have a specific format and currently those are just strings in the schema (see specifications-ITS-JSON/components/RM/Release-1.1.0/Data_types/DV_DATE.json at master · openEHR/specifications-ITS-JSON · GitHub), though the format can be enforced with “format”: “date” in that case.

Note the formats will match this RFC which is a profile of ISO 8601: RFC 3339: Date and Time on the Internet: Timestamps

  1. I have detected that issue while checking an error on a different area: PARTY_RELATIONSHIP.time_validity, which is a DV_INTERVAL, and though I had a badly formatted datetime for the DV_INTERVAL.lower, the validation passed like nothing was wrong.

Then I realized, the DV_INTERVAL is missing any checks on the lower and upper attributes, since this validates against anything:

        "DV_INTERVAL": {
            "type": "object",
            "required": [
                "lower_unbounded",
                "upper_unbounded",
                "lower_included",
                "upper_included"
            ],
            "properties": {
                "lower": {
                    "type": "object"   <<<<
                },
                "upper": {
                    "type": "object"  <<<<
                },
...

Changing that to this will work as expected and give an error if the value is wrong:

            "properties": {
                "lower": {
                    "allOf": [
                        {
                            "required": [
                                "_type"
                            ],
                            "properties": {
                                "_type": {
                                    "type": "string",
                                    "enum": [
                                        "DV_DATE",
                                        "DV_DATE_TIME",
                                        "DV_TIME",
                                        "DV_DURATION",
                                        "DV_ORDINAL",
                                        "DV_PROPORTION",
                                        "DV_COUNT",
                                        "DV_QUANTITY"
                                    ]
                                }
                            }
                        },
                        {
                            "if": {
                                "properties": {
                                    "_type": {
                                        "const": "DV_DATE"
                                    }
                                },
                                "required": [
                                    "_type"
                                ]
                            },
                            "then": {
                                "$ref": "#/definitions/DV_DATE"
                            }
                        },
... all the other cases here ....

Note that validation should be mixed with the format: date/date-time/time/duration in the corresponding DV_XXX.value.

I think it’s worth to add the constraints, at least I have updated my copies with those and now my the JSON validation in Atomik Server is working way better.