Array "type" not supported to json-schema spec: eg. ["number","string"]
Hi. I have posted a question on stackoverflow because I am not able to make my example work (being validated correctly).
I have the form:
[
{
"key":"foo",
"title":"Test",
"type":"string"
}
]
The schema:
{
"type": "object",
"properties": {
"foo": {
"type": ["number","string"],
"maxLength":2,
"minLength":0,
"minimum":3,
"maximum":10
}
}
}
and the model:
{
"foo": "bar"
}
The problem is that the validation tells me that the model is valid, even though it is not according to the json-schema-validator.
when I post my schema and model in the json-schema-validator, my example work. Why is that? Am I doing something wrong in the form?
Yes, it seems like that works there. But I cannot find anywhere in the specification that having multiple values for "type" is supported, albeit a cursory look. The validator for ASF is TV4, perhaps they have some information?
(I am not sure I would use that functionality even if I could, that'd just be moving a problem further along)
Oops, found it. Indeed it can be an array.
A quick look at source shows that array type definition is primarily supported to support ["null","non-null"], given the example the result could only be a string as that is what the form is set to. So given the form has to be set to something it makes supporting opposite types quite difficult which is why I suspect it hasn't been tackled by anyone.
Yes, it is probably for the same reason "anyOf" isn't supported yet.