Skip to content

OneOfValidator is filtering out the required errors if all the oneOf schemas are having the issues. #678

@rahultokase

Description

@rahultokase

We are using the following schema. In the following schema we have

  1. OuterObject with innerObject as a property.
  2. InnerObject is marked as oneOf String or Object with required properties.

{ "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://example.com/issue-470.json", "title": "OneOf validation message", "description": "Test description", "type": "object", "properties": { "outerObject": { "type": "object", "properties": { "innerObject": { "oneOf": [ { "type": "string" }, { "type": "object", "properties": { "value": { "type": "string" }, "unit": { "type": "string" } }, "additionalProperties": false, "required": [ "value", "unit" ] } ] } } } }, "additionalProperties": false }

the above schema was validated with below json data.
{ "outerObject": { "innerObject": {} } }

The errors given by oneOfValidator are
$.letterSpacing.wide: object found, string expected

The expected one was
$.outerObject.innerObject: object found, string expected
$.outerObject.innerObject.value: is missing but it is required
$.outerObject.innerObject.unit: is missing but it is required

After Inspecting the oneOfValidator code we figured out that

  1. we are filtering the required error deliberately in the oneOfValidator. Any Known reason for the same?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions