-
Notifications
You must be signed in to change notification settings - Fork 0
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
oneOf
incorrectly evaluates with a error result of Value not allowed
even when it is valid
#1
Comments
Hi David, thank you for reporting. The behavior you describe is actually a design decision and not a bug. The RuntimeEvaluationResult is currently as verbose as possible in order to be able to understand for debugging purposes exactly why the oneOf schema is valid (in other words, to see exactly which scheme was considered valid). If you want to see whether an error is a "real" error in the result, you can also check the "suppressAnnotation" property, which is true if the error and/or annotations were discarded during the evaluation. It could be useful to implement an option in the output classes that can control the level of result verbosity. Best regards, |
Here is a code example to filter real errors (I have updated the README too):
|
@ro-pi Thank you for the quick response and detailed explanation. I have incorporated checking |
@ro-pi Apologies, but foreach ($results as $result) {
if ($result->error) {
echo "Error keyword location: '{$result->keywordLocation}'\n";
echo "Error instance location: '{$result->instanceLocation}'\n";
echo "Error message: {$result->error}\n";
echo "Annotation suppressed: {$result->suppressAnnotation}";
echo "\n\n";
}
} If I pass
If I pass
|
@davidburtonmr I see, you are right. In this case, of course, all annotations are suppressed. So we need a new property to recognize "real" errors that actually have an influence on the final result. |
@davidburtonmr I've solved this issue and just created a new release (v0.4.0), which now implements a "type" property in RuntimeEvaluationResult, which can be of value "error" or "annotation". The results with the type "error" are obviously actual errors and results with the type "annotation" are informative for debugging purposes in order to be able to understand which schemas and keywords were validated (and how). Best regards, |
@ro-pi Thanks for the fix and a new release, I can confirm that valid values for One notable is I am not getting Results with type error from e.g. requireds or type validations. My guess that only the lowest level error result (usually an allOf in my case) is given type error - which may be exactly what you intended. The schemas I am working with are pretty complicated and not really suitable as an example here, if it would help I can provide a simpler example with result outcomes. |
@davidburtonmr If I have understood you correctly, then the behavior you have described is intentional. The The reason is, because the sub-schema-validation results are not affecting the overall validation result (e.g. if you have the The |
With a schema of:
If you pass
foo
orbar
it correctlyevaluate()
s totrue
, but there is still aRuntimeEvaluationResult
whereerror
isValue is not allowed
.The current unit tests for
oneOf
only cover whether it evaluates to true or false and not the returned results.The text was updated successfully, but these errors were encountered: