qri-io / jsonschema

golang implementation of https://json-schema.org drafts 7 & 2019-09
MIT License
461 stars 54 forks source link

The validate cannot find unknow fields #122

Closed msyesyan closed 2 years ago

msyesyan commented 2 years ago

Hey, I found the validate function cannot find unknow fields.

eg

schema

{
  "type": "object",
  "properties": {
      "person": {
         "name": "string"
      }
  }
}

data

{
  "person": {
     "name": "abc",
     "other": "abc"
  }
}

In this case, the Validate function cannot give any error or warnning message. you can try this one line

https://json-schema-validator.herokuapp.com/

msyesyan commented 2 years ago

https://stackoverflow.com/questions/32044761/json-schema-with-unknown-property-names

we can use additionalProperties: false to solve this problem, thx