Skip to content

"additionalProperties: false" is ignored if type specified in array #404

@elasti-ron

Description

@elasti-ron

Given the object

object = {
  "a_string": "this property is allowed by the schema",
  "an_extra_string": "the schema does not allow this property"
}

The following schema should raise a validation error but doen't:

// should raise error but doesn't
{
  "type": [ "object", "null" ],
  "properties": {
    "a_string": {
      "type": "string"
    }
  },
  "additionalProperties": false
}

This occurs even if only a single type is specified in the array of type options:

// should raise error but doesn't
{
  "type": [ "object" ],
  "properties": {
    "a_string": {
      "type": "string"
    }
  },
  "additionalProperties": false
}

Note that this does not occur when the type is specified directly and not in an array. In other words, the following schema does raise the expected error:

// raises error as expected
{
  "type": "object",
  "properties": {
    "a_string": {
      "type": "string"
    }
  },
  "additionalProperties": false
}

This issue may be related to #369

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