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

Bad error message #19

Open
ghost opened this issue Jan 11, 2022 · 1 comment
Open

Bad error message #19

ghost opened this issue Jan 11, 2022 · 1 comment

Comments

@ghost
Copy link

ghost commented Jan 11, 2022

I have encountered a problem in which an object with keys '1', '2', etc. and values of one type does not pass validation but the error message is wrong.

MySchema: { 1: OtherSchema.required(), 2: OtherSchema.required(), }

My object: { 1: {}, 2: OtherSchemaDTO, }

Validation error:
thrown: Array [ [Error: No such property '1' in . [query: '1']], ]

The object should not pass the validation, not for the lack of property '1', but for the invalidity of object under property '1'. The validation fails with given message even when I don't use an empty object under property '1'.

Edit:
Of course when both objects are proper (of type OtherSchemaDTO) under properties '1' and '2' the validation passes. But when I do myObject[1] = {} and then validate, it fails.

@crobinson42
Copy link

Is this an AJV lib issue (ajv is used under the hood)?

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

No branches or pull requests

1 participant