# `Cardbox.Filter`
[🔗](https://github.com/hattoriai/cardbox/blob/v0.1.0/lib/cardbox/filter.ex#L1)

A condition on a field that a record meets or not.

    %{"field" => "status", "op" => "eq", "value" => "Done"}
    %{"field" => "due", "op" => "within", "value" => "next_week"}
    %{"field" => "owner", "op" => "eq", "value" => "me"}

The operators of a field are those of its type (`Cardbox.Type.operators/1`):

| Operator | Of | Value |
| --- | --- | --- |
| `eq`, `neq` | every type but lists | a value of the field |
| `contains`, `not_contains`, `starts_with`, `ends_with` | texts | a text, without case |
| `gt`, `gte`, `lt`, `lte` | numbers | a number |
| `between` | numbers, dates | `[from, to]`, both included |
| `before`, `after`, `on_or_before`, `on_or_after` | dates | a day |
| `within` | dates | `past_week`, `past_month`, `past_year`, `next_week`, `next_month`, `next_year`, `this_week`, `this_month`, `this_year` |
| `in`, `not_in` | a select, a status, a person | a list of values |
| `in_group` | a status | `todo`, `doing` or `done`, or a list of them |
| `has_any`, `has_all`, `has_none` | multi-selects, relations, people | a list of values |
| `is_empty`, `is_not_empty` | every type that can be empty | none |

A day is `"2026-10-25"`, or a day said in words that is read when the
query runs: `today`, `tomorrow`, `yesterday`, `one_week_ago`,
`one_week_from_now`, `one_month_ago`, `one_month_from_now`. A saved view of
"due within the next week" shows a different week each week.

A person is their id, or `"me"`: the person who runs the query (the
`:me` option of a query), so one shared view of "my tasks" shows each
person theirs.

A choice is its id or its name. "Is not", "does not contain", "is none
of" and "has none of" take the records with no value too, as a person
means them.

# `t`

```elixir
@type t() :: %Cardbox.Filter{field: String.t(), op: atom(), value: term()}
```

# `ranges`

```elixir
@spec ranges() :: [String.t()]
```

The ranges of days that `within` takes.

# `relative_days`

```elixir
@spec relative_days() :: [String.t()]
```

The days said in words that a date filter takes.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
