ajv-validator / ajv-validator/ajv

v7: schema compilation is safer but significantly slower than v6 - using standalone validation code

Abierto
#1,386 6 comentarios 2 reacciones 0 asignados Ver en GitHub
docs
Lenguaje dominante
TypeScript
Estrellas
14.8k
Forks
1k
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

In Serverless Framework we've just upgrade AJV from v6 to v7, and observed that `ajv.compile(schema)` execution time for very same schema jumped from ca `0.15s` to `0.8s`.

Is this a known issue?

It can be observed by running any Serverless Framework command, and measuring execution time at this line:

https://github.com/serverless/serverless/blob/bcbbd47fa09b7d99d7f8da3f11150215d1203bba/lib/classes/ConfigSchemaHandler/index.js#L106

**What version of Ajv are you using? Does the issue happen if you use the latest version?**

v7.0.3

**Ajv options object**

```javascript
{ allErrors: true, coerceTypes: 'array', verbose: true, strict: false }
```

**JSON Schema**

It's a large dynamically generated schema, if needed I can export it to JSON and provide a link

**Your code**

```javascript
const Ajv = require('ajv').default;
const ajv = new Ajv({ allErrors: true, coerceTypes: 'array', verbose: true, strict: false });
ajv.compile(schema);
```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.