getOptionBool
Import from @varavel/vdl-plugin-sdk/utils/options.
function getOptionBool(
options,
key,
defaultValue
): boolean;
Returns a boolean option using common truthy and falsy string values.
Accepted truthy values: true, 1, yes, on, enable, enabled, y.
Accepted falsy values: false, 0, no, off, disable, disabled, n.
Invalid values fall back to the provided default.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | Record<string, string> | undefined | Plugin options record. |
key | string | Option name to read. |
defaultValue | boolean | Value returned when the option is missing or invalid. |
Returns
boolean
The parsed boolean value, or the default when parsing fails.
Example
getOptionBool({ watch: "yes" }, "watch", false);
// returns true