commissaire
commissaire copied to clipboard
Port Model Validation to use jsonschema
Our current model implementation uses a custom validation scheme which can be confusing to folks just jumping in to the code. jsonschema provides a standard way to validate data. Since our underlying transport ends up being json it seems like a perfect fit as noted by @mbarnes.
Library: https://pypi.python.org/pypi/jsonschema
Cluster Model Schema Example
Note: The example isn't tested :grin:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"name": {"type": "string"},
"status": {"type": "string"},
"type": {"type": "string"},
"network": {"type": "string"},
"hostset": {
"type": "array",
"items": {
"pattern": "^[a-zA-Z0-9\:\.\-_]*$",
"type": "string"
}
}
}
Agree. jsonschema seems like a good choice to validate data.