Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-32705

Json schema does not correctly validate an array of enums

    • Type: Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • Labels:
      None
    • ALL
    • Hide

      Given the following Json schema valiator applied to a collection:

      "properties": {
        "values": {
            "bsonType": "array",
            "items": {
              "bsonType": "string",
              "enum": [
                "one",
                "two",
                "three"
              ]
            },
            "minItems": 1,
            "uniqueItems": true
          }
      }
      

      I am still able to insert and also update a document with a 'values' property that contains an invalid value not included in the enum. For example if I insert or update a document via $set containing values ["one", "two", "three", "four"] it still passes validation.

      Show
      Given the following Json schema valiator applied to a collection: "properties": { "values": { "bsonType": "array", "items": { "bsonType": "string", "enum": [ "one", "two", "three" ] }, "minItems": 1, "uniqueItems": true } } I am still able to insert and also update a document with a 'values' property that contains an invalid value not included in the enum. For example if I insert or update a document via $set containing values ["one", "two", "three", "four"] it still passes validation.

      Using a Json schema containing a property with an enum keyword nested inside a items keyword should fail validation on encountering a value not included in the enum array. Currently it passes validation with invalid values included.

            Assignee:
            kyle.suarez@mongodb.com Kyle Suarez
            Reporter:
            etay2000 Eric Tray
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: