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

missingProperty undefined with ownProperties: true #1493

Closed
brigand opened this issue Mar 15, 2021 · 2 comments
Closed

missingProperty undefined with ownProperties: true #1493

brigand opened this issue Mar 15, 2021 · 2 comments

Comments

@brigand
Copy link

brigand commented Mar 15, 2021

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

7.2.1

Ajv options object

const options = {
	ownProperties: true,
};

JSON Schema

{
  "type": "object",
  "required": [
    "a"
  ],
  "properties": {
    "a": {
      "type": "string"
    }
  }
}

Sample data

{}

Your code

const ajv = new Ajv(options);
const foo = ajv.compile(schema);
foo(data);
assert.deepEqual(foo.errors[0], {
  keyword: 'required',
  dataPath: '',
  schemaPath: '#/required',
  params: { missingProperty: undefined },
  message: "should have required property 'undefined'",
});

What results did you expect?

missingProperty should be 'a', and message should reference it instead of undefined.

Are you going to resolve the issue?

If recommended as a good first issue.

@epoberezkin
Copy link
Member

thank you - fixed!

@epoberezkin
Copy link
Member

in 7.2.2

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

No branches or pull requests

2 participants