Argx.WithCheck (Argx v1.1.4)
DSLs for checking args.
configskeyword is necessary and it's content is not empty.define configs directly or reuse rules by name.
wrap multi functions that have different guards.
defmodule YourProject do import YourProject.Validator with_check configs( Rule, id(:integer, :optional, :autoconvert, :empty, 1..99) || get_default_id() ) do def create(id) when is_integer(id) do {:ok, id} end def create(id) when is_bitstring(id) do {:ok, String.to_integer(id)} end end endgetting all arg configs.
- format:
__get_[function_name]_configs__. - such as:
configs = YourProject.__get_create_configs__(). - configs' data type is keyword, sorted by function arg_names.
- format:
Configuration
config Argx or Argx.WithCheck module.
- set shared arg configs module.
- set warn flag.
use Argx.WithCheck, share: YourProject.ArgConfigs, warn: false