exvalibur v0.3.1 Exvalibur.Guards.Default View Source
Default set of guards to be used with Exvalibur.validator!/2
.
Guards are public functions of arity 2, exporting the AST valid as Elixir guard. One might provide their own set of guards by the following config:
config :exvalibur, :guards, MyApp.Guards
Assuming that the file itself looks somewhat like:
defmodule MyApp.Guards do
import Exvalibur.Guards.Default, except: [min_length: 2]
def min_length(var, val) when is_integer(val) do
quote do
is_bitstring(unquote(var)) and bytesize(unquote(var)) >= unquote(val)
end
end
end
Link to this section Summary
Functions
Guard for conditions like %{eq: 1.0}
, exact equality
Guard for conditions like %{greater_than: 1.0}
, like min/2
, but the inequality is strict
Guard for conditions like %{less_than: 1.0}
, like max/2
, but the inequality is strict
Guard for conditions like %{max: 2.0}
, implies actual value is less or equal than the parameter
Guard for conditions like %{max_length: 10}
, checks the byte length of the binary parameter
Guard for conditions like %{min: 1.0}
, implies actual value is greater or equal than the parameter
Guard for conditions like %{min_length: 10}
, checks the byte length of the binary parameter
Guard for checking the excludion from the list like %{not_one_of: [42, 3.14]}
Guard for checking the includion in the list like %{one_of: [42, 3.14]}
Link to this section Functions
Guard for conditions like %{eq: 1.0}
, exact equality
Guard for conditions like %{greater_than: 1.0}
, like min/2
, but the inequality is strict
Guard for conditions like %{less_than: 1.0}
, like max/2
, but the inequality is strict
Guard for conditions like %{max: 2.0}
, implies actual value is less or equal than the parameter
Guard for conditions like %{max_length: 10}
, checks the byte length of the binary parameter
Guard for conditions like %{min: 1.0}
, implies actual value is greater or equal than the parameter
Guard for conditions like %{min_length: 10}
, checks the byte length of the binary parameter
Guard for checking the excludion from the list like %{not_one_of: [42, 3.14]}
Guard for checking the includion in the list like %{one_of: [42, 3.14]}