ExEnv v0.3.1 ExEnv.Utils View Source

ExEnv general utilities.

Link to this section Summary

Functions

Returns :ok if config AST is acceptable, else raises exception

Returns :ok if otp_app is acceptable, else raises exception

Link to this section Functions

Link to this function validate_config_ast(list) View Source

Returns :ok if config AST is acceptable, else raises exception.

Example

  iex> quote do [foo: 123] end |> ExEnv.Utils.validate_config_ast
  :ok
  iex> quote do [1, 2, 3] end |> ExEnv.Utils.validate_config_ast
  :ok
  iex> quote do %{hello: "world"} end |> ExEnv.Utils.validate_config_ast
  :ok
  iex> quote do {:hello, "world"} end |> ExEnv.Utils.validate_config_ast
  :ok
  iex> quote do {:hello, "world", 123} end |> ExEnv.Utils.validate_config_ast
  :ok
  iex> quote do [{Hello.World, [foo: "bar"]}] end |> ExEnv.Utils.validate_config_ast
  :ok
  iex> quote do %Date{year: 1990, month: 1, day: 1} end |> ExEnv.Utils.validate_config_ast
  :ok

  iex> {:__aliases__, [], [Foo, "Bar"]} |> ExEnv.Utils.validate_config_ast
  ** (RuntimeError) wrong submodule "Bar" name in AST chunk {:__aliases__, [], [Foo, "Bar"]}

  iex> quote do Foo.bar("hello") end |> ExEnv.Utils.validate_config_ast
  ** (RuntimeError) invalid or unsafe config AST {{:., [], [{:__aliases__, [alias: false], [:Foo]}, :bar]}, [], ["hello"]}
Link to this function validate_otp_app(otp_app) View Source

Returns :ok if otp_app is acceptable, else raises exception.

Example

  iex> ExEnv.Utils.validate_otp_app(:hello_world)
  :ok
  iex> ExEnv.Utils.validate_otp_app(:hello_123)
  ** (RuntimeError) invalid OTP application name hello_123