数据引用在 everit-org/json-schema 库中被视为数字以验证 JSONSchema

Data ref treated as number in everit-org/json-schema library to validate JSONSchema

我正在使用 https://github.com/everit-org/json-schema 库对 JSON 模式进行服务器端验证,当我在最大验证中使用数据引用时它失败了

我的架构 属性 就像

"fromYear": {
            "array": false,
            "type": "number",
            "title": "From Year",
            "minimum": {
                "$data": "1/toYear"
             },
            "key": "fromYear",
            "required": false
        }

但是当我们调用 Schema 的验证方法时,它会抛出类似

的错误
"#/properties/qualificationsection/items/properties/fromYear/minimum: expected type: Number, found: JsonObject"

JSON 模式支持最小数量以及一个 jsonobject(即,它支持联合类型),我们可以在其中指定数据引用。

库无法处理此问题,因为期望最小值始终为数字类型

$data 在当前(草案 7)中不是 JSON 架构关键字。

一些库尝试实现它,因为它是对未来草案的建议,但它目前不是官方规范的一部分。

除此之外别无选择。目前根本不可能。