Schema for Scalpel Filter Settings

From FilterSettings.schema.yaml (scalpel/FilterSettings.schema)

---
$id: https://skeleton.botmd.io/scalpel/FilterSettings.schema
$schema: http://json-schema.org/draft-07/schema#

title: Filter Settings
description: Schema for storing filter settings.

type: object
additionalProperties: false
required: [type, expression]

_type: &type_title_description
  title: Type
  description: The type of this element.

properties:
  type:
    <<: *type_title_description
    const: expression

  expression:
    title: Expression
    description: Expression of filter.

    type: object
    additionalProperties: false
    required: [expressions]

    properties:
      operator:
        title: Operator
        description: Operator of expressions.

        oneOf:
          - type: object
            required: [type]
            additionalProperties: false

            properties:
              type:
                <<: *type_title_description
                enum: [and, or, not]

          - type: object
            required: [type, at_least]
            additionalProperties: false

            properties:
              type:
                <<: *type_title_description
                const: at_least

              at_least:
                title: At least
                description: An operator that filters any data where at least `N` of the conditions are true

                required: [n]
                additionalProperties: false

                properties:
                  n:
                    title: Number of data
                    description: Number of data where condition is true.

                    type: integer
                    minimum: 1

      expressions:
        title: Expressions
        description: Expressions of data

        type: array
        items:
          oneOf:
            - $ref: "#"
            - type: object
              additionalProperties: false

              properties:
                type:
                  <<: *type_title_description
                  const: condition

                condition:
                  oneOf:
                    - type: object
                      required: [type, Q]
                      additionalProperties: false

                      properties:
                        type:
                          <<: *type_title_description
                          const: Q

                        Q:
                          title: Query
                          description: Django ORM query

                          type: object
                          additionalProperties: false

                          anyOf:
                            - required: [key, string]
                            - required: [key, boolean]
                            - required: [key, string_array]
                            - required: [key, number]
                            - required: [key, datetime]

                          properties:
                            key:
                              title: Query key
                              type: string
                              minLength: 1

                            string:
                              title: String
                              type: string
                              minLength: 1

                            boolean:
                              title: Boolean
                              type: boolean

                            number:
                              title: Number
                              type: integer
                              minimum: 0

                            string_array:
                              title: String Array
                              type: array
                              minItems: 1
                              item:
                                type: string
                                minLength: 1

                            datetime:
                              title: Datetime
                              type: string
                              format: date-time

                            exclude:
                              title: Exclude
                              type: boolean

  exclude:
    title: To exclude data which matches expression in filter_queryset
    type: boolean

[Main Page] [Schema Documentation] [Examples]