Function: Enum()
ts
function Enum<T>(...values): TypeFunction<T>;Defined in: packages/parser/src/flag-types.ts:17
Creates a Enum type function that validates the input against allowed values. The display name will be formatted as "value1 | value2 | ..." for help output.
Type Parameters
| Type Parameter |
|---|
T extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
...values | T[] | Array of allowed string values |
Returns
TypeFunction<T>
A TypeFunction that validates and returns the input value
Throws
If the value is not in the allowed values list
Example
typescript
const format = Enum(["json", "yaml", "xml"]);
// Help output will show: json | yaml | xml
