Closed cashlo closed 6 years ago
I don't understand your schema. How do you expect it to work, when you have "anyOf", "type" and "properties" at the same level?
Have you validated your schema? It does not look valid.
https://www.jsonschemavalidator.net/ takes it fine.
Another way to put it is like this, which works fine:
$v->schema(
{ 'anyOf' => [
{ 'required' => ['test_number'],
'type' => 'object',
'properties' => {
'test_number' => { 'type' => 'number' },
'test_string' => { 'type' => 'string' }
}
},
{ 'required' => ['test_string'],
'type' => 'object',
'properties' => {
'test_number' => { 'type' => 'number' },
'test_string' => { 'type' => 'string' }
}
},
],
}
);
The schema below gives me 3 error with draft4:
{
"type": "object",
"properties": { "test_number": { "type": "number" }, "test_string": { "type": "string" } },
"anyOf": [
{ "required": [ "test_number" ] },
{ "required": [ "test_string" ] }
]
}
How are you able to validate it with zero errors? A screenshot works for me...
You mean for the schema itself?
Or like this? Not too sure how this works
Thanks for the screenshots! It's so weird, but I sometimes get "three errors" when pasting in your schema, but I tried doing some manual changes and then it got validated... Very strange.
Anyways, this is now fixed in 29f34585920c6c6bb6fc3b03b25b15431109d820, but you can fix it manually by adding type=>'object'
while waiting for the new release.
Here's a simple test:
I am expecting a error here, but I get no error. If I switch to oneOf, I get "All of the oneOf rules match.".
Am I missing something here?