Postman: More Descriptive TV4 Verification Error Message

I use postman to check the json data schema returned from api.

I have a test that goes through a basic HTTP check and then ends with:

if (tv4.error){
    console.log("Validation failed: ", tv4.error);
}

The error I am returning is hard to understand.

Verification failed: 12: 22: 41.316
  Object: {}
message: "Invalid type: number (expected string)"
Name: "ValidationError"
Type: "Error"

But I need to know in which field the check was performed. How can I get this information? the npm page for tv4 suggests that the error message should be more visual.

+4
1

tv4 console.log(tv4.error.dataPath), , .

. :

validation false, tv4.error.

:

{
    "code": 0,
    "message": "Invalid type: string",
    "dataPath": "/intKey",
    "schemaPath": "/properties/intKey/type"
}
+4

Source: https://habr.com/ru/post/1681958/


All Articles