Jump to: navigation, search

Difference between revisions of "Ceilometer/ComplexFilterExpressionsInAPIQueries/ValidationWithColander"

Line 1: Line 1:
 
=Colander for complex query filter syntax=
 
=Colander for complex query filter syntax=
  
The goal was to find a way to validate the filter syntax with colander. Here is my brain dump recorded during the process, with all the explanations and wondering http://paste.openstack.org/show/61466/
+
The goal was to find a way to validate the filter syntax with colander. Here is my brain dump recorded during the process, with all the explanations and wondering http://paste.openstack.org/show/61466/ I suggest to read it before jumping to the conclusion.
  
In summary colander is not flexible enough to parse and validate an expression tree with variable node types because:
+
To sum it up colander is not flexible enough to parse and validate an expression tree with variable node types because:
 
* It cannot make validation rules about the key names in a dictionary. If every dynamic data is moved to the values then the type of a value will depend on the content of another value on the same level. This cannot be expressed with colander.  
 
* It cannot make validation rules about the key names in a dictionary. If every dynamic data is moved to the values then the type of a value will depend on the content of another value on the same level. This cannot be expressed with colander.  
 
* If at a key the value can have different types then it cannot be expressed with colander because colander does not support OneOf for types just for validators
 
* If at a key the value can have different types then it cannot be expressed with colander because colander does not support OneOf for types just for validators
  
In the other hand all the above things can be expressed and validated with jsonschema without a need to write loops and conditions.
+
In the other hand all the above things can be expressed and validated with jsonschema without a need to write loops and conditions as proposed in the https://review.openstack.org/#/c/62157/

Revision as of 19:36, 17 January 2014

Colander for complex query filter syntax

The goal was to find a way to validate the filter syntax with colander. Here is my brain dump recorded during the process, with all the explanations and wondering http://paste.openstack.org/show/61466/ I suggest to read it before jumping to the conclusion.

To sum it up colander is not flexible enough to parse and validate an expression tree with variable node types because:

  • It cannot make validation rules about the key names in a dictionary. If every dynamic data is moved to the values then the type of a value will depend on the content of another value on the same level. This cannot be expressed with colander.
  • If at a key the value can have different types then it cannot be expressed with colander because colander does not support OneOf for types just for validators

In the other hand all the above things can be expressed and validated with jsonschema without a need to write loops and conditions as proposed in the https://review.openstack.org/#/c/62157/