简体   繁体   English

TV4:获取检测到的错误的更多详细信息

[英]TV4: to get more details of detected errors

I am using tv4 to detect schema errors. 我正在使用tv4检测架构错误。 I tried getting all results using: tv4.validateMultiple call which detected multiple errors but did not say where or why. 我尝试使用以下tv4.validateMultiple获取所有结果: tv4.validateMultiple调用,该调用检测到多个错误,但未说明在何处或原因。

Is there any way in tv4 to provide more elaborate information of failures? 电视4中有什么方法可以提供更详细的故障信息?

var res = tv4.validateMultiple(data, schema,null,true);

errors:[]
0:{}
message:"Missing required property: coMMand"
name:"ValidationError"
type:"Error"
1:{}
message:"Unknown property (not in schema)"
name:"ValidationError"
type:"Error"
2:{}
message:"Unknown property (not in schema)"
name:"ValidationError"
type:"Error"

I guess this is not possible to do with tv4 and since there is not being any more enhancements to the module. 我想这与tv4无关,并且由于该模块没有更多增强功能。 The ajv on the other hand provides better results: 另一方面,ajv提供了更好的结果:

var ajv = new Ajv({allErrors: true});
//define some schema
schema = {...};
//validate with some invalid schema
ajv.validate(schema,{s:'a'});
console.log(ajv.errors);

Following result is found: 找到以下结果:

dataPath:""
keyword:"additionalProperties"
message:"should NOT have additional properties"
params:{}
additionalProperty:"s"
schemaPath:"#/additionalProperties"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM