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

A condition on a column that a row must meet to be in the grid.

`op` is one of:

  * `:eq` and `:neq`: equal, or not, to `value`;
  * `:contains`, `:not_contains`, `:starts_with` and `:ends_with`: for
    text, without case;
  * `:gt`, `:gte`, `:lt` and `:lte`: greater or less than `value`;
  * `:between`: from the first to the second value of a two-item list,
    both included;
  * `:in`: one of the values of a list;
  * `:is_nil` and `:not_nil`: no value, or any value (with no `value`).

The value is read for the column's type (see `Masu.Column`): a date
column takes `"2026-10-17"` or a `Date`, a number column `"12.5"` or
`12.5`.

# `op`

```elixir
@type op() ::
  :eq
  | :neq
  | :contains
  | :not_contains
  | :starts_with
  | :ends_with
  | :gt
  | :gte
  | :lt
  | :lte
  | :between
  | :in
  | :is_nil
  | :not_nil
```

# `t`

```elixir
@type t() :: %Masu.Filter{key: String.t(), op: op(), value: term()}
```

# `cast`

```elixir
@spec cast(t(), [Masu.Column.t()]) :: {:ok, t()} | {:error, String.t()}
```

Checks a filter against the grid's columns and reads its value for the
column's type. Returns the filter with the value read, or an error that
says why: no such column, a column that does not filter, an operator
that is not for its type, or a value it cannot read.

# `match?`

```elixir
@spec match?(t(), term()) :: boolean()
```

Whether a value meets the filter, as `Masu.Source.List` checks it. The
filter's value must already be read (`cast/2`).

# `new`

```elixir
@spec new(String.t() | atom(), op(), term()) :: t()
```

A filter on the column with `key`.

# `ops`

```elixir
@spec ops() :: [op()]
```

The operators of a filter.

# `ops`

```elixir
@spec ops(Masu.Column.type()) :: [op()]
```

The operators of a filter on a column of `type`: those of text only for text and enums.

---

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