Questions tagged [tv4]

tv4 is a tiny Validator for v4 JSON Schema.

tv4 is a tiny Validator for v4 JSON Schema.

https://github.com/geraintluff/tv4

30 questions
8
votes
1 answer

Postman: More descriptive tv4 validation error message

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…
powlo
  • 2,538
  • 3
  • 28
  • 38
6
votes
1 answer

How do I test JSON schema in postman using tv4?

This is what i am trying, but it always passes the test even for bad results. pm.test("Schema is valid", function () { var data = pm.response.json(); var schema = { ... my schema ... }; tv4.validate(data,…
srayner
  • 1,799
  • 4
  • 23
  • 39
5
votes
1 answer

JSON Schema custom message for oneOf

Is there a way to set a custom message for json schema (tv4) for when it fails at a oneOf field? I saw that there was an issue opened for custom messages about a year ago here and here but is there a way to make this work for something like this? { …
Jeremy
  • 1,717
  • 5
  • 30
  • 49
4
votes
1 answer

Postman always valid as true a response with the schema using tv4

I've did a lot of tests but I coulnd't find the way to solve it. Simplifying, I have this Postman test script to validate that the JSON response es according with the JSON schema defined to this API: const stockQuotesSchema =…
Sebastian Diaz
  • 155
  • 7
  • 19
4
votes
2 answers

javascript regex pattern for _water_glass

I need a javascript regex pattern to test a schema variable, so that it should have either of the following. It can start with any character followed by "_water_glass" and must not be anything after water_glass like "xxxx_water_glass" or It can…
3
votes
2 answers

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

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…
3
votes
3 answers

JSON Schema extract the required fields

I need to get a list of the required fields out of a JSON-Schema+Data. Currently, we are using AJV to get error messages in our forms with JSON Schema and it is working great. I need a way to get all the required fields (even if filled) in order to…
Mike
  • 741
  • 13
  • 40
3
votes
2 answers

Fail to validate schema and correctly use additionalProperties

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, …
Vincent83149
  • 51
  • 2
  • 9
3
votes
1 answer

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

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', …
InnerWorld
  • 585
  • 7
  • 26
2
votes
2 answers

Validate jsonschema against a json array having multiple elements using postman and tv4

Below is my JSON schema { "$schema": "http://json-schema.org/draft-04/schema#", "type": "array", "items": [ { "type": "object", "properties": { "id": { "type": "integer" }, "name": { …
Riyas
  • 299
  • 4
  • 15
2
votes
1 answer

POSTMAN returns fail for schema validation test

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…
Vyacheslav
  • 612
  • 1
  • 9
  • 17
2
votes
1 answer

TV4 JSON Schema array of objects validation

I would like to validate that a property called "foo" contains an array of "bar" objects. Using TV4 for validation all works as expected if I use an array as the value of foo however if I specify something other than an array such as a string or an…
Liam Molloy
  • 21
  • 1
  • 2
1
vote
1 answer

Postman Test - tv4.validateResult TypeError: Cannot read property '$ref' of undefined

I am using postman, i have added a test to validate the schema of the response. The schema and response schema return as expected, but somewhere in the following code i get the error "tv4.validateResult TypeError: Cannot read property '$ref' of…
1
vote
1 answer

Getting "Please add error message" while validating form element in angular schema form

I'm currently using angular-schema-form (https://github.com/json-schema-form/angular-schema-form) to generate forms based on json schema. The form generates as expected but while validating it gives me an error "Please add error message for tv4-xxx"…
1
vote
1 answer

Angular Schema Form - "required" not working select and checkbox fields

I'm new to Angular Schema Form and having some issues with select and checkbox fields required validation. Under $scope.schema I have the select field named designation: "designation": { "title": "Designation", "type": "select", …
biko
  • 510
  • 6
  • 15
1
2