Liquid XML Studio 2019
Required
JSON Schema Editor > Properties > Properties (by name) > Required
Draft 04 Draft 06 Draft 07

Validation

An array of strings, each string names a property that must exit within the instance object.

An object instance is valid against this keyword if its property set contains all elements in this array.

 

The property names within this array do not have to be listed in the 'properties' keyword, they could be valid because they are allowable due to a value in the patternProperties or addittionalProperties.

The list of required properties is not directly exposed via the UI, but can still be manipulated.

 

Required properties that exist within the 'properties' collection are shown with a solid line around them.

Required property is defined in 'properties'
Copy Code
{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "additionalProperties": false,
    "properties": {
        "OptionalProperty": {
            "type": "integer"
        },
        "RequiredProperty": {
            "type": "string"
        }
    },
    "required": [
        "RequiredProperty"
    ]
}

They can be made optional or required using the cardinality right click menu

 

The property must still exist within the instance object, but must validate against a 'patternProperty' or the 'additionalProperties' keywords.

When a property name exists within 'required' properties list, but does not exist in the properties, then it is shown in the user interface as an required property.

Required property is NOT defined in 'properties'
Copy Code
{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "additionalItems": false,
    "required": [
        "UndefinedProperty"
    ]   
}

Required properties can be added via the properties right click menu

A required property can be converted into an actual property using the Property Window 'Convert to Property' setting.

 

 

See Also