Tag: json schema validator

AJVvalidation:数据path不一致

我有一个像这样的AJV模式: // schema.js module.exports = { title: 'task', description: 'A Task Schema', type: 'object', properties: { object_city: { title: 'City', type:'string' }, object_zip: { title: 'Zip Code', type: 'string', maxLength: 5, minLength: 5 } }, required: ['object_zip', 'object_city'], additionalProperties: false }; 当我对这个模式运行我的validationtesting时,丢失object_city的结果是: { keyword: 'required', dataPath: '', schemaPath: '#/required', params: { missingProperty: 'object_city' }, message: […]

如何使用嵌套引用来validationJSON模式

我有一个引用多个模式的JSON模式,使用'$ ref'参数,其模式反过来引用其他模式。 例如。 { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "allOf": [ { "$ref": "xyz.json" } ] } 其中schema xyz.json是: { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "id": { "type": "string", "title": "Identifier"}, "Xid": { "type": "object", "$ref": "pqr.json", "title": "X Identifier"} } } 为了方便起见,我将它们全部放在一个目录中,并尝试使用名为Ajv的库来validation模式,但在编译模式时出现错误: can't resolve reference #/event.json from id 。 我怎样才能validation这样的JSON模式? 我的目标是为所有模式创build一个JavaScript对象模型。 谢谢。

NodeJS JSON模式validation不起作用

我是JSON Schema Validator的完全新手,但我认为它非常强大。 但是,我只是无法validation一个JSON。 这是我的模式 { title: "Example Schema", type: "object", properties: { original_image:{ type: "object", properties: { temp_id: {type: "string"}, url: {type: "string"}, scale:{ type: "object", properties:{ new_width: {type: "number"}, new_height: {type: "number"} }, required:["new_width","new_height"] } }, required:["url","temp_id","scale"] } }, required:["image"] } 这是实际的JSON: { "original_image": { "temp_id": "this is my id", "scale": { "new_width": […]

JSON模式:引用本地子模式

我想引用父JSON模式中的子模式。 这是名为child.json的子模式 { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Child", "description": "Child schema", "type": "object", "properties": { "name": {"type": "string"}, "age": {"type": "integer"} }} 这里是名为parent.json的父模式,并且所有这两个文件都在同一个文件夹中。 我想引用子模式,我这样做: { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Parent", "description": "Parent schema", "type": "object", "properties": { "allOf": [ { "$ref": "file://child.json" } ], "adresse": {"type": "string"} }} 我有一个错误,说没有find文件child.json。 我已经testing了很多,但是任何人都在工作。 谢谢你的帮助

JSON模式:date大于其他

我有这样的JSON模式: { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Operation", "description": "The schema of an operation", "type": "object", "properties": { "id":{ "description": "Unique identifier of the service", "type": "string" }, "description":{ "type": "string" }, "dateDebut":{ "type": "string", "format": "date-time" }, "dateFin":{ "type": "string", "format": "date-time" } } } 我怎样才能在我的模式中说dateFin必须大于dateDebut ?

JSON模式validationaws lambda

我需要validation我的aws lambda事件模式。 我用vandium进行validation。 我有两个不同的情况。 lambda函数仅支持一种types的事件。 喜欢这个 var vandium = require('vandium'); vandium.validation({ name: vandium.types.string().required() }); exports.handler = vandium(function (event, context, callback) { console.log('hello: ' + event.name); callback(null, 'Hello from Lambda'); }); 在这种情况下,只有密钥存在或不存在时, vandium才会生效。 但我需要检查是否有任何额外的密钥存在或不。 lambda函数支持多种types的事件。 喜欢这个 var vandium = require('vandium'); vandium.validation({ operation: vandium.types.string().required(), name: vandium.types.string().required(), }); exports.handler = vandium(function (event, context, callback) { const operation = […]

节点表示JSON-Schema多字段validation

使用express-jsonschema 如何validation两个字段,例如: ("quantity" == 0 && "actualQuantity" == 0) || ("quantity" > 0 && "actualQuantity" > 0)