xeipuuv / gojsonschema

An implementation of JSON Schema, draft v4 v6 & v7 - Go language
2.56k stars 358 forks source link

Can't validate array with multiple items. #336

Open lampnick opened 3 years ago

lampnick commented 3 years ago

My json schema is

{
  "type": "array",
  "items": [
    {
      "type": "object",
      "required": [
        "field1"
      ],
      "properties": {
        "field1": {
          "type": "string"
        },
        "field2": {
          "type": "integer"
        }
      }
    }
  ]
}

need validate json is

[
  {
    "field1": "1599733411",
     "field2": 1
  },
  {
    "field2": "1"
  }
]

field1 is required, field2 is integer, in the json data: field1 is empty,field2 is string , but the validation passed.