Skip to main content
tobool(v) converts v to a boolean. The string "true" becomes true, and "false" becomes false. Boolean values pass through unchanged.

Signature

Example

Read a feature flag from the environment as a string and use it as a boolean condition:
Setting RUN_MIGRATIONS=false in the environment skips the migration task.

Notes

  • Only the strings "true" and "false" are valid inputs. Any other string causes an error.
  • tobool is most useful when a value comes from an environment variable or CLI flag that is inherently a string.