Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: validate filter, sort, range, select #3

Open
ymarcon opened this issue Nov 28, 2024 · 0 comments
Open

feat: validate filter, sort, range, select #3

ymarcon opened this issue Nov 28, 2024 · 0 comments

Comments

@ymarcon
Copy link
Contributor

ymarcon commented Nov 28, 2024

The corresponding json schema would look like this:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "ENAC-IT4R Python SQL Utils",
  "type": "object",
  "properties": {
    "filter": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "$and": {
            "type": "array",
            "items": { "$ref": "#" }
          },
          "$or": {
            "type": "array",
            "items": { "$ref": "#" }
          },
          "$eq": { "type": "string" },
          "$ne": { "type": "string" },
          "$lt": { "type": "number" },
          "$lte": { "type": "number" },
          "$le": { "type": "number" },
          "$gt": { "type": "number" },
          "$gte": { "type": "number" },
          "$ge": { "type": "number" },
          "$ilike": { "type": "string" },
          "$like": { "type": "string" },
          "$contains": {
            "type": "array",
            "items": { "type": "string" }
          },
          "$in": {
            "type": "array",
            "items": { "type": "string" }
          },
          "$nin": {
            "type": "array",
            "items": { "type": "string" }
          },
          "$exists": { "type": "boolean" }
        },
        "additionalProperties": true
      }
    },
    "sort": {
      "type": "array",
      "items": [
        { "type": "string" },
        { "type": "string", "enum": ["ASC", "DESC"], "default": "ASC" }
      ],
      "minItems": 1,
      "maxItems": 2
    },
    "range": {
      "type": "array",
      "items": { "type": "integer" },
      "minItems": 2,
      "maxItems": 2
    },
    "select": {
      "type": "array",
      "items": { "type": "string" },
      "minItems": 0
    }
  },
  "required": ["filter"],
  "additionalProperties": false
}
@ymarcon ymarcon changed the title feat: validate filter, sort, range feat: validate filter, sort, range, select Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant