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

Inaccessible ErrorObject params in TypeScript #1319

Closed
vecerek opened this issue Nov 7, 2020 · 1 comment
Closed

Inaccessible ErrorObject params in TypeScript #1319

vecerek opened this issue Nov 7, 2020 · 1 comment

Comments

@vecerek
Copy link

vecerek commented Nov 7, 2020

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

Your typescript code

const validationError: ajv.ValidationError = new ajv.ValidationError([{
    dataPath: ".someKey",
    keyword: "enum",
    params: { allowedValues: ["1", "2", "3"] },
    schemaPath: "",
}]);
validationError.errors[0].params.allowedValues; // TypeError, see below

Typescript compiler error messages

$ tsc --target ES5 --noImplicitAny --noEmit spec/typescript/index.ts
spec/typescript/index.ts:60:34 - error TS2339: Property 'allowedValues' does not exist on type 'ErrorParameters'.
  Property 'allowedValues' does not exist on type 'RefParams'.

60 validationError.errors[0].params.allowedValues;

Describe the change that should be made to address the issue?
I opened a Draft PR here: #1318.

Are you going to resolve the issue?
I already did, needs review and a bit of help with validating the relationships between keywords and params.

@epoberezkin
Copy link
Member

It's duplicate of #1090 - implemented in v7-beta

@ajv-validator ajv-validator deleted a comment from Bgshanoams Nov 13, 2020
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