tv4


JSON tv4 object valid if true and if other object is present

泄露秘密 提交于 2020-01-05 01:52:10
问题 is possible to validate JSON, if value of object is true, then this object is valid, and if Obj2.included == true is valid, if Obj1.included == true ? This is small piece of schema: 'attachments': { 'type': 'object', 'properties': { 'ZalA': { 'type': 'object', 'properties': { 'included': { 'type': 'boolean' }, 'version': { 'type': 'integer' } }, 'required': [ 'included', 'version' ] }, 'ZalB': { 'type': 'object', 'properties': { 'version': { 'type': 'integer' }, 'included': { 'type': 'boolean

POSTMAN returns fail for schema validation test

只愿长相守 提交于 2019-12-24 01:17:04
问题 I have a sample response: { "tags": [ { "id": 1, "name": "[String]", "user_id": 1, "created_at": "2016-12-20T15:50:37.000Z", "updated_at": "2016-12-20T15:50:37.000Z", "deleted_at": null } ] } I've written a test for the response: var schema = { "type": "object", "properties": { "tags": { "type": "object", "properties": { "id": { "type": "integer" }, "name": { "type": "string" }, "user_id": { "type": "number" }, "created_at": { "type": "string" }, "updated_at": { "type": "string" }, "deleted

Postman: More descriptive tv4 validation error message

扶醉桌前 提交于 2019-12-21 11:01:08
问题 I'm using postman to validate the schema of json data returned from an api. I have a test that runs through basic http validation, then ends with: if (tv4.error){ console.log("Validation failed: ", tv4.error); } The error I get back is difficult to fathom. Validation failed: 12:22:41.316 Object:{} message:"Invalid type: number (expected string)" name:"ValidationError" type:"Error" But I need to know which field the validation failed on. How can I get this info? The npm page for tv4 suggests

Fail to validate schema and correctly use additionalProperties

五迷三道 提交于 2019-12-12 13:25:13
问题 I'm trying to validate my JSON schema and use the additionalProperties: false to confirm there is not other properties. My responseBody look like this: [ { "id": 1234567890987654, "email": "eemail@domain.com", "civility": 0, "firstname": "john", "lastname": "do", "function": null, "phone": null, "cellphone": null, "role": 1, "passwordws": "jdnfjnshn55fff5g8" }, { ...} ] In the postman tests, I add this var schema = { "type": "array", "properties": { "id": {"type":"number"}, "email": {"type":

tv4.validate always return true. Even if my schema not valid i.e.: var == “dummy”

≡放荡痞女 提交于 2019-12-11 02:00:33
问题 tv4.validate will always return true. No matter if schema is valid JSON or even just dummy string. I browse stackoverflow for related issues and banUnknownProperties does not help me As i told i even tried to change schema variable to "dummy" and tv4 still does not find error. That`s my first post on stackoverflow. Sorry if my question not clear. Valid response will be as following [ { "dayOfWeek": "sunday", "openTime": "10:00:00", "closeTime": "14:00:00" }, { "dayOfWeek": "monday", "openTime

Postman: More descriptive tv4 validation error message

拥有回忆 提交于 2019-12-04 04:14:45
I'm using postman to validate the schema of json data returned from an api. I have a test that runs through basic http validation, then ends with: if (tv4.error){ console.log("Validation failed: ", tv4.error); } The error I get back is difficult to fathom. Validation failed: 12:22:41.316 Object:{} message:"Invalid type: number (expected string)" name:"ValidationError" type:"Error" But I need to know which field the validation failed on. How can I get this info? The npm page for tv4 suggests that the error message should be more descriptive. code4j According to the documentation of tv4, you can

工具导航Map