DTMI検証拡張参照

JSONスキーマ検証プロパティを使用してデータ検証ルールを定義できるように、DTMI検証拡張をデジタル・ツイン・モデルに追加します。

デジタル・ツイン・モデルでは、JSONスキーマ検証仕様を使用して、収集データの検証に検証プロパティを追加します。デジタル・ツイン・モデルでのDTMI拡張の使用方法を学習するには、シナリオ: デジタル・ツイン・モデルへのJSONスキーマ検証の追加を参照してください。

  • 文字列や整数などのプリミティブ・プロパティの場合、検証制約は、プロパティまたはテレメトリ定義内のスキーマ・フィールドの横に兄弟プロパティとして追加されます。
  • 配列の場合、検証は配列自体に適用されます。たとえば、minItemsuniqueItemsは配列スキーマの兄弟として定義されますが、配列スキーマ内に配置される値範囲や文字列パターンなどの各要素に適用される制約は、elementSchemaに対する兄弟プロパティです。

IoTプラットフォームでは、次のJSONスキーマ検証キーワードがサポートされています。

  • 数値インスタンス: numberおよびinteger
  • 文字列: "schema": "string"
  • 配列minItemmaxItemsおよびuniqueItems
ノート

exclusiveMinimumおよびexclusiveMaximum検証では、unsignedLongスキーマ・タイプを使用すると、標準longの範囲を超える値を2倍に変換できます。この変換によって精度が失われる可能性があるため、exclusiveMinimumまたはexclusiveMaximumに近い値は、有効であるように見えても検証に合格しない場合があります。
検証データ型これらの@typesで有効です。スキーマ・タイプに適用されます。

exclusiveMinimum

exclusiveMaximum

番号

配列

CommandRequest

CommandResponse

列挙

フィールド

MapValue

プロパティ

テレメトリ

  • (数値)プリミティブ・スキーマ
  • (数値)プリミティブ・スキーマの配列
{
   "@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

番号

配列

CommandRequest

CommandResponse

列挙

フィールド

MapValue

プロパティ

テレメトリ

  • (数値)プリミティブ・スキーマ
  • (数値)プリミティブ・スキーマの配列
{
   "@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

整数

配列

CommandRequest

CommandResponse

列挙

フィールド

MapKey

MapValue

プロパティ

テレメトリ

  • (文字列)プリミティブ・スキーマ
  • (文字列)プリミティブ・スキーマの配列
{
   "@type": "Telemetry",
   "name": "minMaxLengthProperty",
   "schema": "string",
   "minLength": 0,
   "maxLength": 2048
}
{
   "@type": "Property",
   "name": "arrayDataProperty",
   "schema": {
      "@type": "Array",
      "elementSchema": "string",
      "minLength": 1,
      "maxLength": 2048
}
multipleOf番号

配列

CommandRequest

CommandResponse

列挙

フィールド

MapValue

プロパティ

テレメトリ

  • (数値)プリミティブ・スキーマ
  • (数値)プリミティブ・スキーマの配列
{
   "@type": "Telemetry",
   "name": "minMaxProperty",
   "schema": "integer",
   "multipleOf": 2
}
{
   "@type": "Property",
   "name": "arrayDataProperty",
   "schema": {
      "@type": "Array",
      "elementSchema": "integer",
      "multipleOf": 2
}
pattern文字列

配列

CommandRequest

CommandResponse

列挙

フィールド

MapKey

MapValue

プロパティ

テレメトリ

  • (文字列)プリミティブ・スキーマ
  • (文字列)プリミティブ・スキーマの配列
{
   "@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

整数

配列

CommandRequest

CommandResponse

フィールド

MapValue

プロパティ

テレメトリ

配列スキーマ(すべてのプリミティブ型)
{
   "@type": "Property",
   "name": "arrayDataProperty",
   "schema": {
      "@type": "Array",
      "elementSchema": "string"
   },
   "minItems": 1,
   "maxItems": 10
}
uniqueItemsブール値

配列

CommandRequest

CommandResponse

フィールド

MapValue

プロパティ

テレメトリ

配列スキーマ(すべてのプリミティブ型)
{
   "@type": "Property",
   "name": "arrayDataProperty",
   "schema": {
      "@type": "Array",
      "elementSchema": "string"
   },
   "uniqueItems": true
}