Open Asc2011 opened 5 years ago
can you please post the full code sample (e.g. to runkit) as the issue template asked?
so you replaced #address with another id and now it cannot find #address - it's expected behaviour. What is the issue?
For me to further investigate please inline the schema in the sample so it can be seen as a whole and reduce its size to the absolute minimum (remove all definitions, properties, keywords etc. that are not essential to reproduce the error - to the point when removing anything further removes or changes the error).
it's expected behaviour.
yes, that was intentional :-)
I'm not expecting a Exception in cases like :
Because now i need to catch such exceptions and parse the string-contents in order to find the location inside the schema. Since Ajv already knows the dataPath, i'm doing double work to find the location-info (line/column) ? Instead of a exception, i' would prefer to find another 'error' or 'warning' in the resulting errors-array ? Right now i extract such information from the Ajv's-logger-messages. I tried compile/validate/validateSchema ?
This behaviour is correct.
The specification prescribed to ignore unknown formats and unknown keywords during validation - it is not supposed to fail but rather pass.
So it would be incorrect to fail validation in these situations.
Quietly passing validation in case there are undefined formats or keywords creates risk that you would have typo in either of them without knowing it. Ajv has options and methods allowing to control this behaviour and to either ignore these unknown formats/keywords or to whitelist specific ones you want (e.g. if the schema author uses custom formats for which you don’t have implementation and you want to ignore them) - see the docs.
With regards to missing $refs, in case the $ref cannot be resolved validation becomes impossible so returning “false” as validation outcome is incorrect (because the validation outcome is undefined rather than false). Again, there is an option to change the default behaviour.
Throwing the exception is the best way because in most cases schemas are part of your code and do not change during the run time - these situations indicate the problem with your schema and not the failure of the validation.
@epoberezkin : thx for all the gliberish that i did not ask for. During our 'conversation' you notoriously present your perspective on why and how you do the things you do. Which i never questioned ? Nor am i interested in such.
All i asked for was a accurate information about the line/col or JSON-Pointer that i can use without using a RegEx to extract it from a error-string. So that i can pass this loc-info over to a linter which could than direct the user to the source-of-error.
I learned that talking to you is pointless, boring not to say a generous waste-of-time.
So i'll fix that myself now.
regards
@epoberezkin : thx for all the gliberish that i did not ask for. During our 'conversation' you notoriously present your perspective on why and how you do the things you do. Which i never questioned ? Nor am i interested in such. All i asked for was a accurate information about the line/col or JSON-Pointer that i can use without using a RegEx to extract it from a error-string. So that i can pass this loc-info over to a linter which could than direct the user to the source-of-error. I learned that talking to you is pointless, boring not to say a generous waste-of-time. So i'll fix that myself now. regards
@Asc2011 If you had read your own second message, you would have seen that I was replying to it. You wrote: "I'm not expecting a Exception in cases like..." - I explained why I believe it is the correct behaviour for Ajv to throw the exception in such cases.
The issue was submitted as a bug report and your second message stated that the behaviour of Ajv is different from what you expected - it was not clear what is the "bug" you want "fixed".
Ignoring the insults in the last message, I now can see that what you actually asked for was not fixing the bug but adding JSON Pointer to the exception. The issue should have been submitted as a feature request/change proposal - it would have massively simplified understanding.
Just for the future, you should appreciate a bit more the work that open-source contributors are doing to let you use, free of charge, their libraries. It creates value for your projects and allows you to achieve more results while spending less time (earning more money). Open-source contributors are not obliged to answer any questions or provide support. Neither they are obliged to make their libraries do what you expect or want - it is absolutely fair that their libraries only do what they believe is right. You have the choice of not using them if they do not fit your purpose.
What version of Ajv are you using? Does the issue happen if you use the latest version? yes , latest 6.10
Ajv options object
What results did you expect? a dataPath/JSONPointer that identifies the position of the ref "#company".
Are you going to resolve the issue? probably by walking the schema-ast