Skip to content

getOptionString

Import from @varavel/vdl-plugin-sdk/utils/options.

function getOptionString(
   options, 
   key, 
   defaultValue): string;

Returns a string option or the provided fallback when the key is missing.

Unlike the numeric and enum helpers, this function preserves the raw option value exactly as provided, including empty strings.

Parameters

Parameter Type Description
options Record\<string, string> | undefined Plugin options record.
key string Option name to read.
defaultValue string Value returned when the option is missing.

Returns

string

The raw option string, or the default when the key is missing.

Example

getOptionString({ prefix: "Api" }, "prefix", "Model");
// returns "Api"