question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Meta-Schema-Validation not working / no guide available

See original GitHub issue

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

Integrating Ajv2019 from "ajv": "^6.12.6", with Angular

Ajv options object


 const ajv = new Ajv2019({allErrors: true});

JSON Schema

Use case: Trying to validate custom schemas against meta schema draft 2019-09 e.g:


{
    "$schema": "https://json-schema.org/draft/2019-09/schema",
    "$id": "https://example.com/schemas/template.json",
    "title": "Template",
    "type": "object",
    "properties": {},
    "required": [],
    "additionalProperties": false
}

Your code


const ajv = new Ajv2019({allErrors: true});
 valid = ajv.validateSchema(json);
errors = ajv.errors;

Validation result, data AFTER validation, error messages

no schema with key or ref "https://json-schema.org/draft/2019-09/schema"

What results did you expect?

Meta-Schema validation working.

Are you going to resolve the issue?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:16 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
GabenGarcommented, Oct 28, 2022

In my use case the user creates custom schemas and therefore I need to explicitly validate the schema against the meta schema (draft 2019-09) and report any issues with the validation.

Should’ve started with that.

Get the validator function directly then:

const validateMetaSchema = ajv.getSchema("https://json-schema.org/draft/2019-09/schema")
1reaction
epoberezkincommented, Nov 4, 2022

How should validateSchema behave with an instance of Ajv2019?

It would validate it agains draft-2019 meta-schema

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix Schema Validation Errors
In this guide we will go over schema validation errors in more detail; specifically, the most common one, called “either “offers”, “review”, or...
Read more >
Json schema validation shows no errors - Stack Overflow
Your problem is, you have no schema with the $id of http://test.com/schemas/test.json . You need to pass in the identifier (in your case, ......
Read more >
API Reference | Ajv JSON schema validator
The schema passed to this method will be validated against meta-schema unless validateSchema option is false. If schema is invalid, an error will...
Read more >
Schema Validation on Confluent Server
Value schema and key schema validation are independent of each other; you can enable either or both. (By default, schema validation is not...
Read more >
Javascript example of meta-schema v1 - Amazon-Services-API
For JavaScript applications, the Hyperjump - JSON Schema Validator library supports ... The following example code will not work in a web browser,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found