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
173
votes
7 answers

Webpack - Critical dependency: the request of a dependency is an expression

I am getting three warning messages when importing request in a barebone webpack project. A minimal example to reproduce the bug is available on GitHub (run npm install and npm start). Critical dependency: the request of a dependency is an…
Jodiug
  • 5,425
  • 6
  • 32
  • 48
42
votes
1 answer

Why is JOI more popular than AJV?

I am deciding on a validation library that I can use for both client and server side validation. I have been comparing JOI (+ joi-browser) and AJV. As I understand it JOI and AJV can accomplish the same things. AJV can even perform async validation…
tkalis
  • 557
  • 1
  • 5
  • 5
23
votes
4 answers

Can I validate a date using ajv json schema, without converting the date to string?

I have an object which contains one or more properties of type date. I would like to validate the object using the ajv json schema validator package. I could convert the properties of type date to a string by using the toISOString(). But the object…
A. Bolleter
  • 231
  • 1
  • 2
  • 4
22
votes
2 answers

AJV schema validation for array of objects

I am trying to validate array of objects using AJV schema validation. Below is the sample code var Ajv = require('ajv'); var schemaValidator = Ajv(); var innerSchema = { "type" : "object", "properties" : { "c" : { "type" : "string" …
ankit kothana
  • 661
  • 1
  • 5
  • 6
18
votes
4 answers

Error "custom keyword definition is invalid: data.errors should be boolean"

I just created a new React application using this command: create-react-app mysite.com After installation, when I tried to open it using npm start and yarn start, I got the following error. throw new Error('custom keyword definition is invalid: '…
Ishan Patel
  • 5,571
  • 12
  • 47
  • 68
17
votes
1 answer

ajv conditional schema validation based on data

I would like to specify a regexp pattern for one field based on the data in another. Is this possible? I've tried switch and $data but not sure how to use them. for example, if data looks like: { "contacts":[ { "mode":"Email", …
jmaynard
  • 171
  • 1
  • 1
  • 3
12
votes
1 answer

AJV return only one error although there is multiple

I'm trying to use AJV with the below code, when I validate an object with multiple errors, AJV throws only one error at a time. const schema = { type: 'object', properties: { name: {type: 'string', minLength: 1, maxLength: 1}, …
Elbassel
  • 444
  • 7
  • 19
11
votes
1 answer

JSON schema + relative JSON-pointers: how to verify "confirm password" field

Here's my JSON Schema: { "required": [ "username", "password", "confirmPassword" ], "properties": { "username": { "minLength": 3, "type": "string" }, "password": { "minLength": 6, "type":…
mpen
  • 272,448
  • 266
  • 850
  • 1,236
11
votes
5 answers

NodeJS validation library for json objects

I need to validate some object in my NodeJS app. I have already used an awesome library express-validator, it works perfectly, but now I need to validate different object, not only requests and as far as express validator leverages validator…
user4671628
10
votes
3 answers

How do I validate a string using a regular expression with Ajv?

I'm trying to validate a string(Phone number) with this regex ^+[0-9]{9,12}$ but I get this error ... .pattern should match format "regex" ... I've been through the documentation at https://ajv.js.org etc. looked at examples etc. and tried a lot of…
LegionDev
  • 1,391
  • 4
  • 15
  • 29
10
votes
1 answer

How to select node_modules dist flavor to bundled with webpack

Problem: After I upgraded AJV.js to Version 6.4 my vendor bundle includes the "uri-js" ESNEXT version instead the ES5 version what breaks IE11 compatibillity. Analysis: I figured that that AJV referes to uri-js with a require('uri-js') call and that…
Marc
  • 4,715
  • 3
  • 27
  • 34
10
votes
6 answers

Empty values validation in json schema using AJV

I am using Ajv for validating my JSON data. I am unable to find a way to validate empty string as a value of a key. I tried using pattern, but it does not throw appropriate message. Here is my schema { "type": "object", "properties": { …
maria zahid
  • 437
  • 1
  • 6
  • 18
10
votes
1 answer

How add keyword Nullable (or allowNull) into Ajv?

I wrote the following code. var ajv = new require('ajv'); ajv.addKeyword('allowNull', { type: 'null', metaSchema: { type: 'boolean' }, compile: function(allowNullEnable, parentSchema) { return function(data,…
Khusamov Sukhrob
  • 681
  • 1
  • 8
  • 22
10
votes
3 answers

TypeError: Ajv is not a constructor

I have this class where I try to instantiate Ajv with the new keyword and I get this error: TypeError: Ajv is not a constructor Code: import * as Ajv from "ajv"; export class ValidateJsonService { validateJson(json, schema) { …
BeniaminoBaggins
  • 11,202
  • 41
  • 152
  • 287
8
votes
4 answers

TypeError: Ajv is not a constructor when I run npm run build

I'm stumbling on an error every time I run npm run build error: /node_modules/mini-css-extract-plugin/node_modules/schema-utils/dist/validate.js:66 const ajv = new Ajv({ ^ TypeError: Ajv is not a constructor at Object.
Firas SCMP
  • 461
  • 4
  • 18
1
2 3
24 25