JavaScript:JSON 模式验证另一个 JSON 模式
JavaScript: JSON schema to validate another JSON schema
我现在正面临一个应用程序,它需要验证一个表单,其中定义了 JSON 架构。
我想知道 JavaScript
上的 JSON
架构是否有 validator schema
例如:
let validate = schemaValidator.validate('{"title": "Example Schema","type": "object","properties": {"firstName": {"type": "string"},"lastName": {"type": "string"},"age": {"description": "Age in years","type": "integer","minimum": 0}},"required": ["firstName", "lastName"]}', metaSchema);
格式化JSON
{
"title": "Example Schema",
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"description": "Age in years",
"type": "integer",
"minimum": 0
}
},
"required": ["firstName", "lastName"]
}
谢谢,
Schema Draft v4 本身就是一个 JSON 模式,您可以使用它来验证 JSON 模式。
我现在正面临一个应用程序,它需要验证一个表单,其中定义了 JSON 架构。
我想知道 JavaScript
上的JSON
架构是否有 validator schema
例如:
let validate = schemaValidator.validate('{"title": "Example Schema","type": "object","properties": {"firstName": {"type": "string"},"lastName": {"type": "string"},"age": {"description": "Age in years","type": "integer","minimum": 0}},"required": ["firstName", "lastName"]}', metaSchema);
格式化JSON
{
"title": "Example Schema",
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"description": "Age in years",
"type": "integer",
"minimum": 0
}
},
"required": ["firstName", "lastName"]
}
谢谢,
Schema Draft v4 本身就是一个 JSON 模式,您可以使用它来验证 JSON 模式。