Closed JasonSanford closed 12 years ago
the "items" property can indeed be a list of schemas instead of a single schema, so your approach should work just fine from what i can tell, is it not working?
It doesn't seem to be working. I get a Length of list [myTestObject1, myTestObject2] for field 'geometries' is not equal to length of schema list
error. It's almost like it expects that the geometries
array contain the exact number of objects found in the schema. I don't care how many object are in that array. They just need to be one of a few different schemas.
Here's a python script with my schemas and test objects. I keep this in the root of the validictory repo and run python validate.py
to test them.
thanks for the example script, I'll play with this and see if I can get it working
Awesome, Thanks!
If it's of any interest, I'm essentially trying to create a validator for the GeoJSON Spec.
ah I think I have it figured out (it was a weird corner of the spec, which we do support but I hadn't done myself before)
https://gist.github.com/1689852
is an updated version of your file with a slight change to the schema and a test of a failing GeoJSON example too
Pretty neat that you got this working with GeoJSON, probably a good test case for the guys writing the schema
going to close this question, if you encounter a bug in the implementation please do reopen
actually, mind if I borrow part of your example for the documentation to show people how to do this?
Awesome, Thanks a lot! Please share with others. I'm sure someone else will have the same issue as myself.
I thought I'd let you know that I finally got around to writing the GeoJSON validator. See it in action or check out the blog post. Thanks again for your help.
I'm trying to validate an array that can have any number of items in it. Each of these items can be one of 5 or 6 schemas. So, for example:
There are a number of other schemas, but I'm omitting them for brevity.
So, what I need to do is create a GeometryCollection schema that has a
geometries
property that is an array. This array should contain items likeschemaPoint
,schemaLineString
and quite a few others I've not shown here.My first attempt is something like the following:
Essentially what I want in the above is for the
geometries
array above to have any number of items in it, so long as each of those items matches eitherschemaPoint
orschemaLineString
.Am I making any sense?