我在 NodeJs 上使用 AJV(另一个 Json 模式验证器)。
我有以下架构
var schema = {
"$id": "testSchema.json",
"type": "object",
"$schema": "http://json-schema.org/draft-06/schema#",
"additionalProperties": false,
"properties": {
"userId": {
"type": "integer"
},
"userName": {
"type": "string"
},
"uniqueID": {
"type": "integer"
}
}
}
我需要用unqiueID
我可以以某种方式传递给 Json 模式或 AJV 的值覆盖属性。我认为上述可以使用 AJV addKeyword 方法完成,尝试使用它但失败了,因为我不知道如何从 AJV 自定义关键字操作(和返回)数据值。是否可以使用 AJV 修改数据?或者还有其他可能的方法吗?谢谢!