utils/env

Values

pub fn read_optional_bool(
  field_name: String,
  default: option.Option(Bool),
) -> Result(option.Option(Bool), error.EnvFieldError)

Reads an optional boolean environment variable. The value is normalized with string.trim before parsing. Parsing is case-insensitive. Uses default when the field is missing or empty, if provided.

pub fn read_optional_float(
  field_name: String,
  default: option.Option(Float),
) -> Result(option.Option(Float), error.EnvFieldError)

Reads an optional float environment variable. The value is normalized with string.trim before parsing. Uses default when the field is missing or empty, if provided.

pub fn read_optional_int(
  field_name: String,
  default: option.Option(Int),
) -> Result(option.Option(Int), error.EnvFieldError)

Reads an optional integer environment variable. The value is normalized with string.trim before parsing. Uses default when the field is missing or empty, if provided.

pub fn read_optional_string(
  field_name: String,
  default: option.Option(String),
) -> Result(option.Option(String), error.EnvFieldError)

Reads an optional string environment variable. This is not a raw read: the value always goes through string.trim, so leading and trailing whitespace is removed before returning. Uses default when the field is missing or empty, if provided.

pub fn read_optional_with_parser(
  field_name: String,
  default: option.Option(a),
  expected_type: String,
  parser: fn(String) -> Result(a, Nil),
) -> Result(option.Option(a), error.EnvFieldError)

Reads an optional environment variable with a custom parser. The value is normalized with string.trim before parsing. Uses default when the field is missing or empty, if provided.

pub fn read_required_bool(
  field_name: String,
  default: option.Option(Bool),
) -> Result(Bool, error.EnvFieldError)

Reads a required boolean environment variable. The value is normalized with string.trim before parsing. Parsing is case-insensitive. Uses default when the field is missing or empty, if provided.

pub fn read_required_float(
  field_name: String,
  default: option.Option(Float),
) -> Result(Float, error.EnvFieldError)

Reads a required float environment variable. The value is normalized with string.trim before parsing. Uses default when the field is missing or empty, if provided.

pub fn read_required_int(
  field_name: String,
  default: option.Option(Int),
) -> Result(Int, error.EnvFieldError)

Reads a required integer environment variable. The value is normalized with string.trim before parsing. Uses default when the field is missing or empty, if provided.

pub fn read_required_string(
  field_name: String,
  default: option.Option(String),
) -> Result(String, error.EnvFieldError)

Reads a required string environment variable. This is not a raw read: the value always goes through string.trim, so leading and trailing whitespace is removed before returning. Uses default when the field is missing or empty, if provided.

pub fn read_required_with_parser(
  field_name: String,
  default: option.Option(a),
  expected_type: String,
  parser: fn(String) -> Result(a, Nil),
) -> Result(a, error.EnvFieldError)

Reads a required environment variable with a custom parser. The value is normalized with string.trim before parsing. Uses default when the field is missing or empty, if provided.

Search Document