DTMI Validation Extension Reference

Add a DTMI validation extension to your digital twin model so you can define data validation rules using JSON Schema validation properties.

In digital twin models, use JSON Schema Validation Specifications to add validation properties to the validate ingested data. To learn how to use the DTMI extension in your digital twin model, see Scenario: Add JSON Schema Validation to a Digital Twin Model.

  • For primitive properties such as strings or integers, validation constraints are added as sibling properties next to the schema field within the property or telemetry definition.
  • For arrays, validations apply to the array itself such as minItems or uniqueItems are defined as siblings of the array schema, while constraints that apply to each element such as value ranges or string patterns that are placed inside the array schema, as sibling properties to elementSchema.

The IoT platform supports the following JSON schema validation keywords:

  • Numeric Instances including: number and integer
  • Strings: "schema": "string"
  • Arrays minItem, maxItems, and uniqueItems
Note

For exclusiveMinimum and exclusiveMaximum validation, when you use the unsignedLong schema type, values may be converted to doubles if they exceed the range of a standard long. This conversion can result in a loss of precision, so values near the exclusiveMinimum or exclusiveMaximum may not pass validation even if they appear to be valid.
ValidationData TypeValid on these @typesApplies to schema typesExamples

exclusiveMinimum

exclusiveMaximum

Number

Array

CommandRequest

CommandResponse

Enum

Field

MapValue

Property

Telemetry

  • (Numeric) Primitive Schemas
  • Array of (Numeric) Primitive Schemas
{
   "@type": "Telemetry",
   "name": "minMaxProperty",
   "schema": "integer",
   "exclusiveMinimum": 0,
   "exclusiveMaximum": 100
}
{
   "@type": "Property",
   "name": "arrayDataProperty",
   "schema": {
      "@type": "Array",
      "elementSchema": "integer",
      "exclusiveMinimum": 1,
      "exclusiveMaximum": 10
}

minimum

maximum

Number

Array

CommandRequest

CommandResponse

Enum

Field

MapValue

Property

Telemetry

  • (Numeric) Primitive Schemas
  • Array of (Numeric) Primitive Schemas
{
   "@type": "Telemetry",
   "name": "minMaxProperty",
   "schema": "integer",
   "minimum": 0,
   "maximum": 100
}
{
   "@type": "Property",
   "name": "arrayDataProperty",
   "schema": {
      "@type": "Array",
      "elementSchema": "integer",
      "minimum": 1,
      "maximum": 10
}

minLength

maxLength

Integer

Array

CommandRequest

CommandResponse

Enum

Field

MapKey

MapValue

Property

Telemetry

  • (String) Primitive Schemas
  • Array of (String) Primitive Schemas
{
   "@type": "Telemetry",
   "name": "minMaxLengthProperty",
   "schema": "string",
   "minLength": 0,
   "maxLength": 2048
}
{
   "@type": "Property",
   "name": "arrayDataProperty",
   "schema": {
      "@type": "Array",
      "elementSchema": "string",
      "minLength": 1,
      "maxLength": 2048
}
multipleOfNumber

Array

CommandRequest

CommandResponse

Enum

Field

MapValue

Property

Telemetry

  • (Numeric) Primitive Schemas
  • Arrays of (Numeric) Primitive Schemas
{
   "@type": "Telemetry",
   "name": "minMaxProperty",
   "schema": "integer",
   "multipleOf": 2
}
{
   "@type": "Property",
   "name": "arrayDataProperty",
   "schema": {
      "@type": "Array",
      "elementSchema": "integer",
      "multipleOf": 2
}
patternString

Array

CommandRequest

CommandResponse

Enum

Field

MapKey

MapValue

Property

Telemetry

  • (String) Primitive Schemas
  • Array of (String) Primitive Schemas
{
   "@type": "Telemetry",
   "name": "patternProperty",
   "schema": "string",
   "pattern": "^[a-zA-Z]+$"
}
{
   "@type": "Property",
   "name": "arrayDataProperty",
   "schema": {
      "@type": "Array",
      "elementSchema": "string",
      "pattern": "^[a-zA-Z]+$"
}

minItems

maxItems

Integer

Array

CommandRequest

CommandResponse

Field

MapValue

Property

Telemetry

Array Schema (all primitive types)
{
   "@type": "Property",
   "name": "arrayDataProperty",
   "schema": {
      "@type": "Array",
      "elementSchema": "string"
   },
   "minItems": 1,
   "maxItems": 10
}
uniqueItemsBoolean

Array

CommandRequest

CommandResponse

Field

MapValue

Property

Telemetry

Array Schema (all primitive types)
{
   "@type": "Property",
   "name": "arrayDataProperty",
   "schema": {
      "@type": "Array",
      "elementSchema": "string"
   },
   "uniqueItems": true
}