envie
Values
pub fn all() -> dict.Dict(String, String)
Return all environment variables as a Dict(String, String).
pub fn format_errors(errors: List(error.Error)) -> String
Format multiple Error values, one per line.
pub fn format_load_error(err: error.LoadError) -> String
Format a LoadError for display.
pub fn get(name: String) -> Result(String, Nil)
Return the variable’s value as Ok(value), or Error(Nil) if missing.
pub fn get_bool(name: String, default: Bool) -> Bool
Get a boolean variable; returns default if missing or unrecognised.
Accepted truthy: true, yes, 1, on. Falsy: false, no, 0, off.
pub fn get_float(name: String, default: Float) -> Float
Get a float variable; return default if missing or invalid.
pub fn get_int(name: String, default: Int) -> Int
Get an integer variable; return default if missing or invalid.
pub fn get_string(name: String, default: String) -> String
Get a string variable, fall back to default when missing.
pub fn get_string_list(
name: String,
separator separator: String,
default default: List(String),
) -> List(String)
Split a variable by separator into trimmed, non-empty strings.
pub fn load() -> Result(Nil, error.LoadError)
Load variables from .env in the current directory; does not overwrite existing vars.
pub fn load_from(path: String) -> Result(Nil, error.LoadError)
Load variables from path; existing environment variables are preserved.
pub fn load_from_string(
content: String,
) -> Result(Nil, error.LoadError)
Load variables from .env formatted content; does not overwrite by default.
pub fn load_from_string_override(
content: String,
) -> Result(Nil, error.LoadError)
Load variables from content, overwriting existing variables.
pub fn load_override() -> Result(Nil, error.LoadError)
Like load, but overwrite existing variables with .env values.
pub fn load_override_from(
path: String,
) -> Result(Nil, error.LoadError)
Load from path, overwriting existing variables.
pub fn optional(
name: String,
decoder: decode.Decoder(a),
) -> Result(option.Option(a), error.Error)
Decode an optional variable: Ok(None) if missing, Ok(Some(v)) if valid, otherwise Error.
pub fn parse_dotenv(
content: String,
) -> Result(List(#(String, String)), List(error.ParseError))
Parse .env content into key/value pairs; returns parse errors if any.
pub fn require(
name: String,
decoder: decode.Decoder(a),
) -> Result(a, error.Error)
Require a variable and decode it with decoder.
Returns Ok(value) or an Error describing missing/invalid input.
pub fn require_bool(name: String) -> Result(Bool, error.Error)
Require a boolean variable. Accepts the usual true/false aliases.
pub fn require_float(name: String) -> Result(Float, error.Error)
Require a float variable.
pub fn require_float_range(
name: String,
min min: Float,
max max: Float,
) -> Result(Float, error.Error)
Require a float within [min, max].
pub fn require_int(name: String) -> Result(Int, error.Error)
Require an integer variable.
pub fn require_int_list(
name: String,
separator separator: String,
) -> Result(List(Int), error.Error)
Require a list of integers split by separator.
pub fn require_int_range(
name: String,
min min: Int,
max max: Int,
) -> Result(Int, error.Error)
Require an integer within [min, max].
pub fn require_non_empty_string(
name: String,
) -> Result(String, error.Error)
Require a non-empty (trimmed) string.
pub fn require_one_of(
name: String,
allowed: List(String),
) -> Result(String, error.Error)
Require that a variable equals one of the allowed strings.
pub fn require_port(name: String) -> Result(Int, error.Error)
Require a TCP/UDP port number (1–65535).
pub fn require_string(
name: String,
) -> Result(String, error.Error)
Require a string variable.
pub fn require_string_list(
name: String,
separator separator: String,
) -> Result(List(String), error.Error)
Require a list of strings split by separator.
pub fn require_string_prefix(
name: String,
prefix prefix: String,
) -> Result(String, error.Error)
Require a string that starts with prefix.
pub fn require_url(name: String) -> Result(uri.Uri, error.Error)
Require a valid URL (permissive).
pub fn require_url_with_scheme(
name: String,
schemes: List(String),
) -> Result(uri.Uri, error.Error)
Require a URL that has one of the given schemes.
pub fn require_web_url(
name: String,
) -> Result(uri.Uri, error.Error)
Shortcut for require_url_with_scheme(name, ["http", "https"]).