【问题标题】:Number constraints in JSON Schema ValidationJSON Schema Validation 中的数量限制
【发布时间】:2014-04-15 09:35:21
【问题描述】:

我正在处理 JSON 模式验证。我想知道是否可以施加数量限制,如果可以,如何。

例如:

{
    "$schema": "http://json-schema.org/simpleSchema",
    "properties": {
        "birthYear": {
            "type":"number"
        },
        "deathYear": {
            "type":"number"
        },
        "name": {
            "type":"string"
        }
    }
}

我想做这样的事情:

birthYear <= deathYear

我该怎么做?这样的约束是否有特定的关键字?

非常感谢。

若昂

【问题讨论】:

    标签: json numbers constraints jsonschema


    【解决方案1】:

    JSON Schema 不支持引用其他属性的约束。

    请参阅5.1. Validation keywords for numeric instances (number and integer) 了解可能的情况。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-17
      • 1970-01-01
      • 2018-07-05
      • 2021-01-15
      • 2016-02-27
      • 2020-12-26
      • 2020-08-20
      • 1970-01-01
      相关资源
      最近更新 更多