Questions tagged [ajv]

Ajv is a JSON schema validators for node.js and browser. It supports draft 4, 6, and 7, and additional extras beyond JSON Schema that make it more useful.

Ajv is a JSON Schema validator for Node.js and the browser. It supports draft 4, 6, and 7, and additional extras beyond JSON Schema that make it more useful.

Related tags:

375 questions
0
votes
1 answer

Prevent AJV from mutating the object

Whenever we pass in input for validation, AJV will output the validated input. But it mutates the original input. Is there a way to prevent this?
Zanko
  • 4,298
  • 4
  • 31
  • 54
0
votes
1 answer

Nodejs: SyntaxError Exception - "Unexpected token new" faced while trying to require ajv.js

Exception occurred while trying to require Ajv module. var Ajv = require('C:/../node_modules/ajv/lib/ajv.js') Exception occurred in vm.js at function createScript(code, options) { return new Script(code, options); } Exception has occurred:…
Ulysses
  • 5,616
  • 7
  • 48
  • 84
0
votes
1 answer

Validate property key from property data in JSON Schema

I need to validate the following: Json data: { tag: 'picture', picture: 'some string '} Json schema: { tag: {'type': 'string'}, ??????? // The second key should be the data value of the 'tag' Edit: I wish to accomplish this with ajv schema…
Kshateesh
  • 571
  • 1
  • 8
  • 21
0
votes
1 answer

Json Schema AJV not: const: error message is obscure

I find it very hard to work with the error message from Ajv when using notin my schema. In my use case, I want to validate two props not being of the same value. Consider this example: schema.json { "$schema":…
Jakob Hohlfeld
  • 1,503
  • 1
  • 17
  • 31
0
votes
1 answer

Ajv conditional schema based on property value true or false

"data": { "type": "systems", "attributes": { "display_name": "Meals", "is_generic": false, "interaction_object": "BlahBlah" }, "relationships": { "account": { "data": { "type": "accounts", …
0
votes
1 answer

How to describe and validate an array of objects with cuid as key and value as an object with specific properties

I have a unique data that I am attempting to validate: { "name": "Some random name", "blocks": [ {"cj5458hyl0001zss42td3waww": { "quantity": 9, "rate": 356.77, …
ahlusar1989
  • 349
  • 5
  • 16
0
votes
1 answer

Fix wrong JSON values with Ajv

I am trying to fix property values when they have different value than specified. JSON: { "stone": "bri" } I want to fix the stone property to have "brick" if it is not already "brick". Schema: { "required": [ "stone" ], …
Z T
  • 543
  • 1
  • 7
  • 26
0
votes
1 answer

Typescript compile time error

How do I get rid of this compile time typescript error? import * as Ajv from "ajv"; export class ValidateJsonService { validateJson(json, schema) { let ajv = new Ajv.default({ allErrors: true }); if (!ajv.validate(schema, json))…
BeniaminoBaggins
  • 11,202
  • 41
  • 152
  • 287
0
votes
1 answer

Customized schema resolving for invalid objects with AJV

I'm trying to find a way to alter schema validation to find most appropriate schema for a given object. Let's say we have a schema: { "oneOf": [ { "$ref": "#/definitions/a" }, { "$ref": "#/definitions/b" } ], …
0
votes
1 answer

Keys in One Object Must be the Same as Keys in Another Object

Initial Setting You have a JavaScript object for keeping configs, it may be extended by plugins, each plugin has a version and one property on the configs object. const CONFIGS = { plugins: { plugins: { version: '0.15' }, // Plugins is a…
ilyaigpetrov
  • 3,657
  • 3
  • 30
  • 46
0
votes
1 answer

JSON Validation using AJV

I have the following JSON validation var schema = { "type": "object", "required": ["name", "profession"], "properties": { "name": { "type": "string" }, "profession": { "oneOf": [ { "$ref":…
Chums
  • 1
  • 3
-1
votes
1 answer

TypeScript Ajv Circular Structure

Using Ajv on NodeJS, I can't seem to get a circular TypeScript structure to be defined in Ajv. A simple circular structure works (see "parent"), but I can't get an array to work (see "children"). Uncomment the "children" lines to see the error. 'use…
J. McNerney
  • 576
  • 4
  • 15
-1
votes
1 answer

AJV: can't get any context with { passContext: true } since "this" is undefined in user-defined keyword function

I can't get any context data in my custom keyword although I set passContext and bind this with validate.call({ context }, values). made a reproduction repo, in which "this" is ajv instance but still no context available. so I'd appreciate it if…
Otani Shuzo
  • 1,118
  • 1
  • 11
  • 22
-1
votes
1 answer

Working with Polymer 2.0 and require

I am trying to incorporate the JSON Schema validator ajv into a Polymer 2.0 component. It can be loaded with npm npm install ajv I am having a problem instantiating ajv within a Polymer 2.0 component. Accessing ajv is done through the require: var…
Loren Cahlander
  • 1,257
  • 1
  • 10
  • 24
-2
votes
1 answer

Is there a reliable JSON Schema validator library which can be used easily in the browser (script src) and by Node.js?

Most libraries, it seems, do not support easy use in browsers. Isn't there a reliable JSON Schema validator library which I can load into my browser just as easily as many other libraries? It would be extra great if it was available as a Node.js…
1 2 3
24
25