bpdusk / jsonschema

Automatically exported from code.google.com/p/jsonschema
0 stars 0 forks source link

Problems with the spec #19

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
First, at least one of the example schemas are not valid javascript. in
particular

{"description":"A person",
 "type":"object",

 "properties": {
    "name": {"type":"string"},
    "born" : {"type":["integer","string"], allow for a numeric year, or a
full date
          "minimum":1900, min/max for when a numberic value is used
          "maximum":2010,

          "format":"date-time", format when a string value is used
          "optional":true}
    ],
    "gender" : {"type":"string",
                "options":[

                   {"value:"male","label":"Guy"},

                   {"value":"female","label":"Gal"}]},
    "address" : {"type":"object",
                 "properties":{

                    "street":{"type":"string"},
                    "city":{"type":"string"},
                    "state":{"type":"string"}
                   }
                 }

  }
}

Please notice the extra bracket. 

Furthermore, if you attempt to fix this schema and then validate, the
validator complains that it is not valid schema (the error array contains
one object who's message is " Invalid schema/property definition". here is
my fixed version:

{
    "description": "A person",
    "type": "object",
    "properties": {
        "name": {
            "type": "string"
        },
        "born": {
            "type": ["integer", "string"],
            "minimum": 1900,
            "maximum": 2010,
            "format": "date-time",
            "optional": true
        },
        "gender": {
            "type": "string",
            "options": [
                {"value": "male","label":"Guy"}, 
                {"value": "female","label":"Gal"}
            ]
        },
        "address" : {
            "type": "object",
            "properties": {
                "street": {"type":"string "},
                "city": {"type":"string "},
                "state": {"type":"string "}
            }
        }
    }
}

This looks valid to me.

It would be nice to see some more examples and perhaps even a test case or
three.

Original issue reported on code.google.com by javaj...@gmail.com on 25 Jan 2010 at 8:21

GoogleCodeExporter commented 8 years ago
It would also be great if the error message pointed out which part of the 
schema is
invalid. Thanks.

Original comment by javaj...@gmail.com on 25 Jan 2010 at 8:22

GoogleCodeExporter commented 8 years ago
Hey there! First, thanks for writing JSON schema, because it's actually pretty 
neat.
I bet it will be used more in the future. I think it's great the validator is a
single 200 line file. I got into the code and solved my issue. If you want help
sprucing up the spec page, let me know.

Original comment by javaj...@gmail.com on 26 Jan 2010 at 3:12