Validation Rules in Schemas

There are times when our data validations are conditional on other fields based on their situational usage. These validations are called “Group Validations”. They aren’t described verbosely in the /rest/v1 Redocly set, but they are described in a data entity’s schema.

E.g. When a checkpoint’s scanActionType is the enum “MESSAGE”, then a Scan Action Message is required

GET /rest/v1/checkpoints/schema

Beginning at line 1064:

"allOf": [
                {
                    "if": {
                        "required": [
if field==>                 "scanActionType"
                        ],
                        "properties": {
                            "scanActionType": {
                                "enum": [
 has==>                             "MESSAGE"
                                ]
                            }
                        }
                    },
                    "then": {
                        "properties": {
                            "scanActionMessage": {
                                "x-ttc-labels": {
                                    "label": "Scan Action Message",
                                    "description": "Only set a scan action message, when 'Scan Action Type' is 'Message'"
                                },
                                "description": "Only set a scan action message, when 'Scan Action Type' is 'Message'",
                                "deprecated": false,
                                "allOf": [
                                    {
                                        "$ref": "#/components/schemas/TextArea"
                                    }
                                ],
                                "minLength": 1
                            }
                        },
required==>              "required": [
                            "scanActionMessage"
                        ]
                    }
                }
Was this article helpful?
0 out of 0 found this helpful

Articles in this section