Filtrex.Condition is an abstract module for parsing conditions.
To implement your own condition, add use Filtrex.Condition in your module and implement the three callbacks:
parse/2- produce a condition struct from a configuration and attributestype/0- the description of the condition that must match the underscore version of the module's last namespacecomparators/0- the list of used query comparators for parsing params
Summary
Functions
List out the available condition modules
Parses a params key into the condition type, column, and comparator
Parses a condition by dynamically delegating to modules
Generates an error description for a generic parse error
Generates an error description for a parse error resulting from an invalid value type
Helper method to validate that a comparator is in list
Helper method to validate whether a value is in a list
Helper method to validate whether a value is a binary
Callbacks
Functions
List out the available condition modules
Parses a params key into the condition type, column, and comparator
Parses a condition by dynamically delegating to modules
It delegates based on the type field of the options map (e.g. Filtrex.Condition.Text for the type "text").
Example Input:
config:
Filtrex.Condition.parse([
%Filtrex.Type.Config{type: :text, keys: ~w(title comments)}
], %{
type: string,
column: string,
comparator: string,
value: string,
inverse: boolean # inverts the comparator logic
})
Generates an error description for a generic parse error
Generates an error description for a parse error resulting from an invalid value type
Helper method to validate that a comparator is in list
Helper method to validate whether a value is in a list
Helper method to validate whether a value is a binary