Locospec

Filter Spec

Define flexible, nested, and composable filters using conditions and logical groups.

Filters in Locospec define how data should be queried, constrained, and sliced. They’re used across select actions, views, scopes, and search, and support simple conditions as well as complex nested logic.

The filter system is designed to be:

  • 🔄 Reusable
  • 🧱 Composable
  • 🔎 Deeply expressive

✅ Supported Filter Formats

Locospec supports three formats for defining filters:

1. Filter Group (nested, composable)

{
  "op": "and",
  "conditions": [
    { "attribute": "status", "op": "is", "value": "active" },
    {
      "op": "or",
      "conditions": [
        { "attribute": "role", "op": "is", "value": "admin" },
        { "attribute": "role", "op": "is", "value": "manager" }
      ]
    }
  ]
}

✅ Best for complex, nested filters ✅ Used in views, scopes, and select actions

2. Array of Conditions (flat)

[
  { "attribute": "status", "op": "is", "value": "active" },
  { "attribute": "verified", "op": "is", "value": true }
]

✅ Flat structure, easy to parse ✅ Recommended for dynamic builders (like frontend UIs)

3. Key-Value Map (simple)

{
  "status": "active",
  "verified": true
}

✅ Quick and readable ✅ Used in shorthand filters


🔧 Supported Operators

OperatorDescription
isExact match (=)
is_notNot equal (!=)
greater_thanGreater than (>)
less_thanLess than (<)
greater_than_or_equalGreater than or equal (>=)
less_than_or_equalLess than or equal (<=)
containsSubstring match (LIKE %value%)
not_containsSubstring mismatch (NOT LIKE %value%)
is_any_ofValue is in list (IN (...))
is_none_ofValue not in list (NOT IN (...))
is_emptyField is null or empty
is_not_emptyField is not null

📂 Definition: condition

{
  "attribute": "status",
  "op": "is",
  "value": "active"
}
KeyTypeDescription
attributestringThe field to apply the condition on
opstringOne of the supported operators
valuestring, number, boolean, array, nullThe value to compare to

📚 Definition: filterGroup

{
  "op": "or",
  "conditions": [
    { "attribute": "type", "op": "is", "value": "internal" },
    { "attribute": "type", "op": "is", "value": "external" }
  ]
}
KeyTypeDescription
opstringLogical operator: "and" or "or"
conditionsarrayArray of conditions or nested filter groups

🧪 Example: Filter

 

📎 Spec Reference

👉 common.json

On this page