Skip to content

Instantly share code, notes, and snippets.

@Zegnat
Last active August 26, 2022 23:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zegnat/11eb8c0b3f23dae20c380d296564d5ae to your computer and use it in GitHub Desktop.
Save Zegnat/11eb8c0b3f23dae20c380d296564d5ae to your computer and use it in GitHub Desktop.
JSON Schema for validating JSON representations of Kendo filters.
{
"$schema": "http:\/\/json-schema.org\/draft-04\/schema#",
"definitions": {
"filter": {
"oneOf": [
{
"type": "object",
"properties": {
"field": {
"type": "string",
"minLength": 1
},
"operator": {
"enum": [
"eq",
"neq",
"lt",
"lte",
"gt",
"gte",
"startswith",
"endswith",
"contains"
]
},
"value": {
"type": [
"string",
"number"
]
}
},
"required": [
"field",
"operator",
"value"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"field": {
"type": "string",
"minLength": 1
},
"operator": {
"enum": [
"isnull",
"isnotnull",
"isempty",
"isnotempty"
]
}
},
"required": [
"field",
"operator"
],
"additionalProperties": false
}
]
},
"combinator": {
"type": "object",
"properties": {
"logic": {
"enum": [
"and",
"or"
]
},
"filters": {
"type": "array",
"items": {
"anyOf": [
{
"$ref": "#\/definitions\/filter"
},
{
"$ref": "#\/definitions\/combinator"
}
]
}
}
},
"required": [
"logic",
"filters"
],
"additionalProperties": false
}
},
"oneOf": [
{
"$ref": "#\/definitions\/filter"
},
{
"$ref": "#\/definitions\/combinator"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment