Filtr.Plugin behaviour (filtr v1.0.1)

Copy Markdown View Source

Plugin behaviour

Summary

Functions

Returns all registered plugins including DefaultPlugin.

Finds plugin that support the given type. Returns nil if no plugins support the type.

Types

cast_result()

@type cast_result() :: {:ok, any()} | {:error, binary() | [binary()]}

validate_result()

@type validate_result() ::
  :ok | :error | boolean() | {:ok, any()} | {:error, binary() | [binary()]}

validator()

@type validator() :: {atom(), term()}

Callbacks

cast(type, value, opts)

(optional)
@callback cast(type :: atom(), value :: any(), opts :: keyword()) :: cast_result()

types()

@callback types() :: [atom()]

validate(type, value, validator, opts)

(optional)
@callback validate(
  type :: atom(),
  value :: any(),
  validator :: validator(),
  opts :: keyword()
) ::
  validate_result()

Functions

all()

@spec all() :: [module()]

Returns all registered plugins including DefaultPlugin.

find_for_type(type)

@spec find_for_type(atom()) :: [module()] | nil

Finds plugin that support the given type. Returns nil if no plugins support the type.