jdorn / json-editor

JSON Schema Based Editor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

oneOf - Failed to match exactly one schema

monxu-rp opened this issue · comments

Hi,

I have the following jsonschema:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "title": "Contact Form",
  "properties": {
    "email": {
      "type": "string",
      "title": "Your email address",
      "format": "email"
    },
    "questions": {
      "identifier": "1",
      "title": "How can we help you?",
      "default": null,
      "options": {
        "keep_oneof_values": false
      },
      "oneOf": [
        {
          "title": "Select one ...",
          "type": "object",
          "minProperties": 1
        },
        {
          "title": "Question1",
          "type": "object",
          "identifier": "2",
          "properties": {
            "question_1": {
              "title": "Please select one of the following",
              "type": "string",
              "default": "null",
              "enum": [
                "option11",
                "option12"
              ]
            }
          }
        },
        {
          "title": "Question2",
          "type": "object",
          "identifier": "3",
          "properties": {
            "question_2": {
              "title": "Please select one of the following",
              "type": "string",
              "default": "null",
              "enum": [
                 "option21",
                 "option22"
              ]
            }
          }
        },
        {
          "title": "Question3",
          "type": "object",
          "properties": {
            "question_3": {
              "type": "null"
            }
          }
        }
      ]
    },
    "description": {
      "type": "string",
      "title": "Description",
      "format": "text",
      "description": "Please enter the details of your request.",
      "required": true,
      "minLength": 10
    }
  },
  "additionalProperties": false,
  "required": [
    "email",
    "questions",
    "description"
  ]
}

When I'm trying to validate it it always give me the same error:

{
    property: "questions", pointer: "/questions",
    message: "Failed to match exactly one schema",
    constraint: "oneOf", context: 1
}

I have tried to search about that error but I couldn't find anything.

Any reason why this happen? What I'm doing wrong?

Thanks in advance.

This repo is no longer maintained (see also #800)

Development is continued at https://github.com/json-editor/json-editor

For details please visit json-editor/json-editor#5