Filtrex v0.1.0 Filtrex.Condition behaviour
Filtrex.Condition
is an abstract module for parsing conditions.
Summary
Functions
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 whether a value is in a list
Helper method to validate whether a value is a binary
Functions
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(%{
text: %{keys: ~w(title comments)} # passed to the specific condition
}, %{
type: string, # converted to Filtrex.Condition."__" dynamically
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
Specs
validate_in(any, List.t) :: nil | any
Helper method to validate whether a value is in a list
Specs
validate_is_binary(any) :: nil | String.t
Helper method to validate whether a value is a binary