Argx.WithCheck (Argx v1.0.4)

Usage

  • configs keyword 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.Argx
    
      with_check configs(
                     Rule,
                     id(:integer, :optional, :auto, :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
    end
  • getting 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.

Configuration

config Argx or Argx.WithCheck module.

  1. set shared arg configs module.
  2. set warn flag.
    use Argx.WithCheck, share: YourProject.ArgConfigs, warn: false