Validating json

Ajv treats JSON schemas as trusted as your application code.This security model is based on the most common use case, when the schemas are static and bundled together with the application.Dojo, may redefine global require in such way that is not compatible with Common JS module format.In such case Ajv bundle has to be loaded before the framework and then you can use global Ajv (see issue #234).You should add in the keyword or format definition (see add Format, add Keyword and Defining custom keywords).If your schema uses asynchronous formats/keywords or refers to some schema that contains them it should have if you want to return custom errors from the keyword function).

If you need to use Ajv in several bundles you can create a separate UMD bundle using if no module system is found. Ajv is tested with these browsers: Please note: some frameworks, e.g.

You can also supply any other transpiler as a function via property (if the schema is asynchronous), so you can differentiate these functions if you are using both synchronous and asynchronous schemas.

Validation result will be a promise that resolves with validated data or rejects with an exception See Options.

CLI is available as a separate npm package ajv-cli. If you want to create a plugin that implements some of them, it should remove these keywords from the instance.

Ajv implements formats defined by JSON Schema specification and several other formats.

Leave a Reply