Postman: More descriptive tv4 validation error message

拥有回忆 提交于 2019-12-04 04:14:45
code4j

According to the documentation of tv4, you can print the path of the error location using console.log(tv4.error.dataPath), I have no idea why this attribute is not logged in the console.

Documentation is here. The relevant section in the documentation is:

If validation returns false, then an explanation of why validation failed can be found in tv4.error.

The error object will look something like:

{
    "code": 0,
    "message": "Invalid type: string",
    "dataPath": "/intKey",
    "schemaPath": "/properties/intKey/type"
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!