Skip to content

Releases: ajv-validator/ajv

v7.0.0-beta.4

10 Nov 07:38
Compare
Choose a tag to compare
v7.0.0-beta.4 Pre-release
Pre-release

JSON Schema draft-2019-09 support with option draft2019:

  • keyword unevaluatedProperties/unevaluatedItems
  • dynamic recursive references - see Extending recursive schemas
  • additional keywords: dependentRequired, dependentSchemas, maxContains/minContains

v7.0.0-beta.3

05 Nov 08:09
Compare
Choose a tag to compare
v7.0.0-beta.3 Pre-release
Pre-release

Added the new keywords from draft 2019-09:

  • unevaluatedProperties and unevaluatedItems (require option unevaluated to be supported). Please note that an additional generated code may be added to track evaluated properties, even if these keywords are not used).
  • dependentProperties and dependentSchemas (require option next to be supported). These keywords replaced dependencies that is still supported though for draft-7 compatibility.
  • maxContains and minContains (require option next to be supported). See docs and examples here

v7.0.0-beta.2

24 Oct 18:10
Compare
Choose a tag to compare
v7.0.0-beta.2 Pre-release
Pre-release
  • Export additional types
  • Prevent optimiser from removing assignments with side effects when (for user keywords that modify data and have valid: true option)
  • This version is compatible with ajv-keywords v4.0.0-beta.0 and ajv-formats v0.4.0

v7.0.0-beta.1

10 Oct 17:41
Compare
Choose a tag to compare
v7.0.0-beta.1 Pre-release
Pre-release

See v7.0.0-beta.0 for changes from v6.

Switched to syntax tree for code generation.

Added code optimizations:

  • removes empty and unreachable branches.
  • removes unused variable declarations.
  • replaces variables that are used only once and assigned expressions that are explicitly marked as "constant" (i.e. having referential transparency) with the expressions themselves.

These optimizations reduce the size of generated code by more than 10% (based on the tests), removing over 16% of statements in compiled code.

Option code.optimize to control optimization - one optimization pass by default.

See Code optimization for more details.

v6.12.6

10 Oct 17:11
Compare
Choose a tag to compare

Fix performance issue of "url" format.

v7.0.0-beta.0

23 Sep 19:31
Compare
Choose a tag to compare
v7.0.0-beta.0 Pre-release
Pre-release

Please note - this document covers the changes from Ajv v6.

The current latest beta version is v7.0.0-beta.4 - see the releases beta.1-beta.4 in addition to the below.

The main changes

  • to reduce the mistakes in JSON schemas and unexpected validation results, strict mode is added - it prohibits ignored or ambiguous JSON Schema elements. See Strict mode and Options for more details
  • to make code injection from untrusted schemas impossible, code generation is fully re-written to be type-level safe against code injection via untrusted schemas.
  • to simplify Ajv extensions, the new keyword API that is used by pre-defined keywords is available to user-defined keywords - it is much easier to define any keywords now, especially with subschemas.
  • schemas are compiled to ES6 code (ES5 code generation is supported with an option).
  • to improve reliability and maintainability the code is migrated to TypeScript.

Please note:

  • the support for JSON-Schema draft-04 is removed - if you have schemas using "id" attributes you have to replace them with "$id" (or continue using version 6 that will be supported until 02/28/2021).
  • all formats are separated to ajv-formats package - they have to be explicitly added if you use them.

Better TypeScript support:

  • Methods compile and compileAsync now return type-guards - see Getting started.
  • Method validate is a type-guard.
  • Better separation of asynchronous schemas on type level.
  • Type utility JSONSchemaType that generates the type for JSON Schema for type interface in the type parameter - it simplifies writing schemas (no unions support at the moment).

API changes:

  • addVocabulary - NEW method that allows to add an array of keyword definitions.
  • addKeyword - keyword name should be passed as property in definition object, not as the first parameter (old API works with "deprecated" warning). Also "inline" keywords support is removed, code generation keywords can now be defined with "code" keyword - the same definition format that is used by all pre-defined keywords
  • Ajv no longer allows to create the instance without new keyword (it is ES6 class).

Added options (and defaults):

  • strict: true - strict mode
  • strictTypes: "log" - prevent mistakes related to type keywords and keyword applicability (see Strict Types)
  • strictTuples: "log" - prevent incomplete tuple schemas (see Prohibit unconstrained tuples)
  • allowUnionTypes: false - allow multiple non-null types in "type" keyword
  • allowMatchingProperties: false - allow overlap between "properties" and "patternProperties" keywords
  • loopEnum: Infinity - optimise validation of enums, similar to loopRequired
  • validateFormats: true - enable format validation

Changed options:

  • keywords - now expects the array of keyword definitions (old API works with "deprecated" warning)

Removed options:

  • errorDataPath - was deprecated, now removed.
  • format - validateFormats: false can be used instead, old format mode can be chosen via ajv-formats package.
  • nullable: nullable keyword is supported by default.
  • jsonPointers: JSONPointers are used to report errors by default, jsPropertySyntax: true (deprecated) can be used if old format is needed.
  • extendRefs: $ref siblings are validated by default (consistent with draft 2019-09), ignoreKeywordsWithRef (deprecated) can be used instead to ignore $ref siblings.
  • missingRefs: now exception is always thrown. Pass empty schema with $id that should be ignored to ajv.addSchema.
  • processCode: replaced with code: {process: (code, schemaEnv: object) => string}.
  • sourceCode: replaced with code: {source: true}.
  • schemaId: removed, as JSON Schema draft-04 is no longer supported.
  • strictDefaults, strictKeywords, strictNumbers: it is default now, controlled with strict.
  • uniqueItems: '"uniqueItems" keyword is always validated.
  • unknownFormats: the same can be achieved by passing true for formats that need to be ignored via ajv.addFormat or formats option.
  • cache and serialize: Map is used as cache, schema object as key.

v7.0.0-alpha.1

17 Sep 17:38
Compare
Choose a tag to compare
v7.0.0-alpha.1 Pre-release
Pre-release

Pre-release - please ignore

v7.0.0-alpha.0

15 Sep 15:06
Compare
Choose a tag to compare
v7.0.0-alpha.0 Pre-release
Pre-release

Pre-release of Ajv v7-beta version that is due end of September.

Unless you want to experiment with the new version, it is recommended to continue using v6 until the following releases with proper release notes.

This release is needed to update related package(s).

v6.12.5

13 Sep 16:25
Compare
Choose a tag to compare

Fix uri scheme validation (@ChALkeR).
Fix boolean schemas with strictKeywords option (#1270)

v6.12.4

15 Aug 09:11
Compare
Choose a tag to compare

Fix: coercion of one-item arrays to scalar that should fail validation (failing example).