基于另一个值的最小值 - JSON 模式

问题描述 投票:0回答:1

我想根据另一个字段在一个字段上设置最小金额。

例如,如果我有

quoteAmountLower
quoteAmountUpper
- 我希望
quoteAmountUpper
大于
quoteAmountLower

如果下限为 50,则上限必须大于 50。

properties: {
  quotedAmountLower: {
    type: 'integer',
    minimum: 0
  },
  quotedAmountUpper: {
    type: 'integer',
    // more than quotedAmountLower
    minimum: 0
  }
}

干杯

我尝试在

quotedAmountLower

上使用引用或 $id
jsonschema json-schema-validator
1个回答
0
投票

标准 JSON Schema 规范中没有可以引用实例中的值的关键字。

有一些建议,例如https://docs.json-everything.net/schema/vocabs/data-2023/(相关:https://github.com/json-schema-org/json-schema -spec/issues/51)因此您可能需要自定义您正在使用的 JSON Schema 库或检查它是否支持类似的东西。

© www.soinside.com 2019 - 2024. All rights reserved.