1

I have the following schema and json, the json schema validation is failing on the log property as it could not find value "yes" on the instance. The same thing passes in the validator tool https://www.jsonschemavalidator.net/ but not in my code. I don't know what is going on

[u'yes'] is not one of ['no', 'yes']

Failed validating 'enum' in schema['properties']['systems']['items']['properties']['log']: {'enum': ['no', 'yes']}

On instance['systems'][0]['log']: [u'yes']

Schema

{
     "signatures": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },                  
                  "log": {
                    "enum": ["no", "yes"]
                  }                  
                },
                "additionalProperties": false
            } 
          }
}

JSON

{
    "signatures": [
        {                       
            "description": "Protocol",             
            "name": "attempt_1",            
            "log": [
                "yes"
            ],             
            "id": "1550",             
        }
      ]
 }
  • Are you sure the JSON Schema you've provided is correct? It currently doesn't express any constraints (which is why the web based validator reports passing validation). – Relequestual Nov 18 '19 at 12:12
  • @Relequestual - I figured out what was going wrong. "[u'yes'] is a list with "yes" as its only member. It should be expecting a string "yes" that is present in the enum. I fixed this and it works now. – Kishore Khan Nov 19 '19 at 18:10
  • Glad you solved it! Simple errors are sometimes often the hardest to track down – Relequestual Nov 19 '19 at 22:30

0 Answers0