Base filters
DefaultFilter
Section titled “DefaultFilter”The default filter model is a base model that can be used to create more specific filter models.
| Property | Type | Required | Description |
|---|---|---|---|
| operator | one of the enums below | Yes | The operator to apply to the filter value |
| value | any | Yes | The value to use for the filter operation |
Formats
Section titled “Formats”A JSON example of this model.
{ "operator": "eq", "value": null}The JSON Schema for this model.
$schema: https://json-schema.org/draft/2020-12/schema$id: DefaultFilter.yamltype: objectproperties: operator: anyOf: - $ref: EquivalenceOperators.yaml - $ref: ComparisonOperators.yaml - $ref: ArrayOperators.yaml - $ref: StringOperators.yaml - $ref: RangeOperators.yaml - $ref: AllOperators.yaml description: The operator to apply to the filter value value: description: The value to use for the filter operationrequired: - operator - valueunevaluatedProperties: not: {}description: A base filter model that can be used to create more specific filter modelsThe TypeSpec code for this model.
/** A base filter model that can be used to create more specific filter models */model DefaultFilter { /** The operator to apply to the filter value */ operator: | EquivalenceOperators | ComparisonOperators | ArrayOperators | StringOperators | RangeOperators | AllOperators;
/** The value to use for the filter operation */ value: unknown;}The Python code for this model.
class DefaultFilter(CommonGrantsBaseModel): """Base class for all filters that matches Core v0.1.0 DefaultFilter structure."""
operator: Union[ EquivalenceOperator, ComparisonOperator, ArrayOperator, StringOperator, RangeOperator, ] = Field(..., description="The operator to apply to the filter value") value: Union[str, int, float, list, dict] = Field( ..., description="The value to use for the filter operation", )The TypeScript code for this model.
export const DefaultFilterSchema = z.object({ operator: AllOperatorsEnum, value: z.unknown(),});EquivalenceOperators
Section titled “EquivalenceOperators”Operators that filter a field based on an exact match to a value. Supported value types include:
- string
- number
- boolean
- date
- money
| Operator | Description | Property | True value | False value |
|---|---|---|---|---|
| eq | Equal to a value | "foo" | "foo" | "bar" |
| neq | Not equal to a value | "foo" | "bar" | "foo" |
Formats
Section titled “Formats”A JSON example of this model.
"eq"The JSON Schema for this model.
$schema: https://json-schema.org/draft/2020-12/schema$id: EquivalenceOperators.yamltype: stringenum: - eq - neqdescription: Operators that filter a field based on an exact match to a valueThe TypeSpec code for this model.
/** Operators that filter a field based on an exact match to a value */enum EquivalenceOperators { /** Equal to a value */ eq,
/** Not equal to a value */ neq,}The Python code for this model.
class EquivalenceOperator(StrEnum): """The operator to apply to the filter."""
EQUAL = "eq" NOT_EQUAL = "neq"The TypeScript code for this model.
export const EquivalenceOperatorsEnum = z.enum(["eq", "neq"]);ComparisonOperators
Section titled “ComparisonOperators”Operators that filter a field based on a comparison to a value. Supported value types include:
- number
- date
- money
| Operator | Description | Property | True value | False value |
|---|---|---|---|---|
| gt | Greater than a value | 10 | 15 | 5 |
| gte | Greater than or equal to a value | 10 | 10 | 9 |
| lt | Less than a value | 10 | 5 | 15 |
| lte | Less than or equal to a value | 10 | 10 | 11 |
Formats
Section titled “Formats”A JSON example of this model.
"gt"The JSON Schema for this model.
$schema: https://json-schema.org/draft/2020-12/schema$id: ComparisonOperators.yamltype: stringenum: - gt - gte - lt - ltedescription: Operators that filter a field based on a comparison to a valueThe TypeSpec code for this model.
/** Operators that filter a field based on a comparison to a value */enum ComparisonOperators { /** Greater than a value */ gt,
/** Greater than or equal to a value */ gte,
/** Less than a value */ lt,
/** Less than or equal to a value */ lte,}The Python code for this model.
class ComparisonOperator(StrEnum): """Operators that filter a field based on a comparison to a value."""
GREATER_THAN = "gt" GREATER_THAN_OR_EQUAL = "gte" LESS_THAN = "lt" LESS_THAN_OR_EQUAL = "lte"The TypeScript code for this model.
export const ComparisonOperatorsEnum = z.enum(["gt", "gte", "lt", "lte"]);StringOperators
Section titled “StringOperators”Operators that filter a field based on a string value.
| Operator | Description | Property | True value | False value |
|---|---|---|---|---|
| like | Like | "hello" | "hell" | "world" |
| notLike | Not like | "hello" | "world" | "hell" |
Formats
Section titled “Formats”A JSON example of this model.
"like"The JSON Schema for this model.
$schema: https://json-schema.org/draft/2020-12/schema$id: StringOperators.yamltype: stringenum: - like - notLikedescription: Operators that filter a field based on a string valueThe TypeSpec code for this model.
/** Operators that filter a field based on a string value */enum StringOperators { /** Like */ like,
/** Not like */ notLike,}The Python code for this model.
class StringOperator(StrEnum): """Operators that filter a field based on a string value."""
LIKE = "like" NOT_LIKE = "notLike"The TypeScript code for this model.
export const StringOperatorsEnum = z.enum(["like", "notLike"]);ArrayOperators
Section titled “ArrayOperators”Operators that filter a field based on an array of values. Supported value types include:
- string
- number
| Operator | Description | Property | True value | False value |
|---|---|---|---|---|
| in | In an array of values | "A" | ["A", "B"] | ["B", "C"] |
| notIn | Not in an array of values | "A" | ["B", "C"] | ["A", "B"] |
Formats
Section titled “Formats”A JSON example of this model.
"in"The JSON Schema for this model.
$schema: https://json-schema.org/draft/2020-12/schema$id: ArrayOperators.yamltype: stringenum: - in - notIndescription: Operators that filter a field based on an array of valuesThe TypeSpec code for this model.
/** Operators that filter a field based on an array of values */enum ArrayOperators { /** In an array of values */ in,
/** Not in an array of values */ notIn,}The Python code for this model.
class ArrayOperator(StrEnum): """Operators that filter a field based on an array of values."""
IN = "in" NOT_IN = "notIn"The TypeScript code for this model.
export const ArrayOperatorsEnum = z.enum(["in", "notIn"]);RangeOperators
Section titled “RangeOperators”Operators that filter a field based on a range of values. Supported value types include:
- number
- date
- money
| Operator | Description | Property | True value | False value |
|---|---|---|---|---|
| between | The value must be between the two values | 5 | {"min": 1, "max": 10} | {"min": 10, "max": 20} |
| outside | The value must be outside the two values | 5 | {"min": 10, "max": 20} | {"min": 1, "max": 10} |
Formats
Section titled “Formats”A JSON example of this model.
"between"The JSON Schema for this model.
$schema: https://json-schema.org/draft/2020-12/schema$id: RangeOperators.yamltype: stringenum: - between - outsidedescription: Operators that filter a field based on a range of valuesThe TypeSpec code for this model.
/** Operators that filter a field based on a range of values */enum RangeOperators { /** Between a range of values */ between,
/** Outside a range of values */ outside,}The Python code for this model.
class RangeOperator(StrEnum): """Operators that filter a field based on a range of values."""
BETWEEN = "between" OUTSIDE = "outside"The TypeScript code for this model.
export const RangeOperatorsEnum = z.enum(["between", "outside"]);