Argx.WithCheck (Argx v1.0.3)

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 get(id) when is_integer(id) do
          {:ok, id}
        end
        def get(id) when is_bitstring(id) do
          {:ok, String.to_integer(id)}
        end
      end
    end

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