Fltr.Filter (fltr v0.1.0)

Copy Markdown View Source

Types for canonical filter expressions and parse errors.

Most applications interact with the parse/1, to_expr/1, and type aliases generated in a module that uses Fltr. The types here describe the shared representation used by those modules.

Summary

Types

A canonical tuple for one declared filter.

The operator for a Boolean group.

A reason external input could not be converted to a canonical filter.

t()

A canonical leaf filter or a Boolean group containing at least one expression.

Types

filter()

@type filter() :: tuple()

A canonical tuple for one declared filter.

The first element is the filter name and the remaining elements are its validated arguments, for example {:active} or {:id, 7}.

group_operator()

@type group_operator() :: :any | :all

The operator for a Boolean group.

:all requires every child expression; :any requires at least one.

parse_error()

@type parse_error() ::
  {:invalid_filter, term()}
  | {:unknown_filter, String.t() | atom()}
  | {:invalid_arguments, atom(), [term()]}

A reason external input could not be converted to a canonical filter.

  • :invalid_filter identifies an unsupported input shape.
  • :unknown_filter identifies a name not declared by the filter module.
  • :invalid_arguments identifies the original arguments when their count is wrong or a custom parser rejects them.

t()

@type t() :: filter() | {group_operator(), [t(), ...]}

A canonical leaf filter or a Boolean group containing at least one expression.