Disallowing Null Property Values

Without preventing it using the schema itself, null values for a property are not allowed. You can combine the validation type (e.g. "string" for the orderNote in the example below) with an additional allowance for "null", as shown.

Data Schema Example
{
  "primaryKey": "orderNumber",
  "type": "object",
  "properties": {
    "orderNumber": {
      "type": "number",
      "minLength": 3
    },
    "customerName": {
      "type": "string",
      "minLength": 1
    },
    "orderNote": {
      "type": [
        "string",
        "null"
      ]
    }
  },
  "required": [
    "orderNumber", 
    "customerName"
  ],
  "additionalProperties: false
}

Last updated