okfn/openspending — Issue #289: Refactor model validator to procedural validation
Author: pudo
Created: 2011-11-11 08:27:18+00:00
State: open

The model validation code is currently using Colander for validation. This works for the most part but model validation has a lot of very specific business rules that we should validate. Since hardly any of them match the kind of validation Colander does it may make sense to just use a linear, procedural style of validation and not to do try to wrestle this into colander. Putting it in is probably possible, but I get the feeling its less readable.

Some rules:

* A dimension named "time" must exist, it must be "date"
* A dimension named "amount" must exist, it must be "measure"
* A dimension or measure may not be called "id" or contain "__" or any in a list of forbidden words.
* If a compound dimension named "foo" exists, there may not be an attribute dimension named "foo_id" (FK conflict)
* Compound dimensions may not have an attribute "id"
* Compound dimensions must have an attribute "name" of datatype "id"
* If a compound dimension has an attribute "color", it must be "string"
* If a compound dimension has an attribute "parent", it must be "id"