makyo / polycul.es

Graphing polyamorous relationships with force directed layouts.
MIT License
99 stars 25 forks source link

validate received graph against json schema #27

Closed wheresalice closed 6 years ago

wheresalice commented 7 years ago

Validates the graph being saved to make sure that it is actually json and validate it using a jsonschema.

I've not added a check against the size of the graph as per #7 but I could do. The limit is 10^9 characters according to the sqlite spec (unless you override at runtime or have an old sqlite version).

wheresalice commented 7 years ago

Oh hang on, with all those optional fields the schema is a lot more complicated than I've assumed. I'll rework the schema at the weekend. I'm going to have to fully understand this schema if I'm to implement #21

wheresalice commented 7 years ago

I've updated the schema to cover the optional fields, done a bit of refactoring of the schema, added some tests around the schema, and added a tool to validate all the existing graphs in the database. This should all be good to go now.

validate_db.py will print all of the hashes in the sqlite database, along with the errors they cause (or None)

test_validation.py tests the json schema validation against a single node, a single node with all parameters set, a single node with unexpected parameters, a basic link, and a fully described link.

schema.json uses json-schema.org version 4.0

I'd appreciate if the validate_db script could be run against the production database to see if it finds anything that should be valid but isn't allowed by the schema I've written.

makyo commented 6 years ago

I'll be honest, I haven't kept up to date on this. Last I looked was when it needed a bit of time, and then I must've missed the comments about updating. I'm super sorry about that, I didn't mean to let it languish!

I'd really like to see this in play, though, so I'll put some effort into getting it landed today.