Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference Error with relative JSON pointer #100

Open
Skida12138 opened this issue Apr 29, 2021 · 1 comment
Open

Reference Error with relative JSON pointer #100

Skida12138 opened this issue Apr 29, 2021 · 1 comment
Labels

Comments

@Skida12138
Copy link

Package Versions:

node@v14.16.1
ajv@8.1.0
ajv-errors@3.0.0

Problem

Hi when I was trying belowed case I got a ReferenceError: data1 is not defined from my node. It seems that ajv's scheme compiler generates wrong code. When I change schema.foo.bar's type definition or reduce the nesting levels the same error will not occurred again.

const Ajv = require('ajv');
const ajv = new Ajv({ allErrors: true });
require('ajv-errors')(ajv);
const schema = {
  type: "object",
  properties: {
    foo: {
      type: "object",
      properties: {
        bar: {
          type: "string",
          errorMessage: "${0}",
        },
      },
    },
  },
};
const data = {
  foo: {
    bar: false,
  },
};
ajv.validate(schema, data);
console.log(ajv.errors);

Sincerely hope for replying.

@Skida12138
Copy link
Author

I figured out how to solve this, just use ajv with option code: { optimize: 0 }, seems ajv's optimizer will cut the unused name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants