-
Notifications
You must be signed in to change notification settings - Fork 336
Description
Let's suppose that we have a schema like the one below:
{
"type": "object",
"oneOf": [
{
"type": "object",
"required": ["name"],
"properties": {
"name": {
"type": "string",
"pattern": "^Name1$"
}
}
},
{
"type": "object",
"required": ["name"],
"properties": {
"name": {
"type": "string",
"pattern": "^Name2$"
}
}
},
{
"type": "object",
"required": ["name"],
"properties": {
"name": {
"type": "string",
"pattern": "^Name3$"
}
}
}
]
}
Let's also suppose that we have the below json to validate:
{
"name": "UnknownName"
}
If we were to validate the described json against the schema, then the validator will fail successfully. However, we'll also get 3 errors that don't quite make sense in this sort of situation.
These are the errors that we'd get:
[
"$.name: does not match the regex pattern ^Name1$",
"$.name: does not match the regex pattern ^Name2$",
"$.name: does not match the regex pattern ^Name3$"
]
The problem with these errors is that "$.name" only needs to match one of those patterns, but every single error encountered underneath the oneOf is reported.
It almost seems like the ValidationMessage should be a tree structure. The root validation problem has to do with the oneOf validation. However, there are child errors that caused the oneOf to fail. These child errors could be grouped together for each of the schemas within the oneOf.
[
{
"message" : "$ must match at least one of the valid schemas",
"children" : [
[{ "message" : "$.name: does not match the regex pattern ^Name1$" }],
[{ "message" : "$.name: does not match the regex pattern ^Name2$" }],
[{ "message" : "$.name: does not match the regex pattern ^Name3$" }],
]
]
Maybe this isn't too big of a deal, but it still seems a little weird to me. If it's not that big of deal then we can just close this issue. I just thought I'd bring it up so that it can be discussed.