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
minItemsoruniqueItemsare 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 toelementSchema.
The IoT platform supports the following JSON schema validation keywords:
- Numeric Instances including:
numberandinteger - Strings:
"schema": "string" - Arrays
minItem,maxItems, anduniqueItems
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.| Validation | Data Type | Valid on these @types | Applies to schema types | Examples |
|---|---|---|---|---|
| Number | Array CommandRequest CommandResponse Enum Field MapValue Property Telemetry |
| |
| Number | Array CommandRequest CommandResponse Enum Field MapValue Property Telemetry |
| |
| Integer | Array CommandRequest CommandResponse Enum Field MapKey MapValue Property Telemetry |
| |
multipleOf | Number | Array CommandRequest CommandResponse Enum Field MapValue Property Telemetry |
| |
pattern | String | Array CommandRequest CommandResponse Enum Field MapKey MapValue Property Telemetry |
| |
| Integer | Array CommandRequest CommandResponse Field MapValue Property Telemetry | Array Schema (all primitive types) | |
uniqueItems | Boolean | Array CommandRequest CommandResponse Field MapValue Property Telemetry | Array Schema (all primitive types) | |