Lamina.DSL.Config (lamina v0.2.2)
Defines the macros used inside the config
macro.
Link to this section Summary
Functions
Specify a transformation function to cast the value to the final required type.
Specify a validation function to ensure that the value is valid.
Link to this section Functions
Specs
Specify a transformation function to cast the value to the final required type.
Some configuration providers (most notably Env
) are only able to return
strings, so it can be necessary to modify them before they're returned to the
user.
Example
defmodule MyHttpServer.Config do
use Lamina
provider(Lamina.Provider.Env)
config :listen_port do
cast(&String.to_integer/1)
end
end
Specs
Specify a validation function to ensure that the value is valid.
Gives you an opportunity to ensure that the value about to be returned to the user is correct.
Example
defmodule MyFileReader.Config do
use Lamina
provider(Lamina.Provider.Env)
config :file_to_read do
validate(fn
"/etc/password" -> false
_ -> true
end)
end
end