Search code examples
arraysregexuuidjsonschema

Mix of objects and arrays


I am trying to structure the json-schema after a json response I want to send.

I have tried several versions of object->array->object->array, but it does not seem like I can validate an UUID key with a regex using patternProperties

The JSON looks like this:

 [{
    "54ffe69-b8f6-47c8-9437-ccea8ecc2d77": {
        "name": "ORC",
        "$description": "Design polar from ORC",
        "source": {
            "label": "signalk-polar"
        },
        "polarData": [{
            "trueWindSpeed": 3.086666667,
            "beatAngles": [
                0.738274274
            ]
        }]
    }
 }]

Solution

  • Not really sure, it might be something wrong with the UUID that you are trying to validate. It is though accepting this pattern:

    [0-9a-f]{7}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}
    

    but, according to this post, we should have had:

    [0-9a-f]{8}
    

    in the starting part, or I might be wrong.

    Demo