1- import type { FlagTypeFunction } from "./types" ;
1+ import type { TypeFunction } from "./types" ;
22
33/**
44 * Creates a Enum type function that validates the input against allowed values.
55 * The display name will be formatted as "value1 | value2 | ..." for help output.
66 *
77 * @param values - Array of allowed string values
8- * @returns A FlagTypeFunction that validates and returns the input value
8+ * @returns A TypeFunction that validates and returns the input value
99 * @throws {Error } If the value is not in the allowed values list
1010 *
1111 * @example
@@ -14,7 +14,7 @@ import type { FlagTypeFunction } from "./types";
1414 * // Help output will show: json | yaml | xml
1515 * ```
1616 */
17- export function Enum < T extends string > ( ...values : T [ ] ) : FlagTypeFunction < T > {
17+ export function Enum < T extends string > ( ...values : T [ ] ) : TypeFunction < T > {
1818 const fn = ( ( value : string ) => {
1919 if ( ! values . includes ( value as any ) ) {
2020 throw new Error (
@@ -23,7 +23,7 @@ export function Enum<T extends string>(...values: T[]): FlagTypeFunction<T> {
2323 }
2424
2525 return value ;
26- } ) as FlagTypeFunction < T > ;
26+ } ) as TypeFunction < T > ;
2727
2828 fn . display = values . join ( " | " ) ;
2929
@@ -35,10 +35,10 @@ export function Enum<T extends string>(...values: T[]): FlagTypeFunction<T> {
3535 *
3636 * @param min - The minimum acceptable value (inclusive)
3737 * @param max - The maximum acceptable value (inclusive)
38- * @returns A FlagTypeFunction that validates the input value
38+ * @returns A TypeFunction that validates the input value
3939 * @throws {Error } If the value is not a number or is outside the specified range
4040 */
41- export function Range ( min : number , max : number ) : FlagTypeFunction < number > {
41+ export function Range ( min : number , max : number ) : TypeFunction < number > {
4242 const fn = ( ( value : string ) => {
4343 const num = Number ( value ) ;
4444 if ( Number . isNaN ( num ) || num < min || num > max ) {
@@ -48,7 +48,7 @@ export function Range(min: number, max: number): FlagTypeFunction<number> {
4848 }
4949
5050 return num ;
51- } ) as FlagTypeFunction < number > ;
51+ } ) as TypeFunction < number > ;
5252 fn . display = `${ min } -${ max } ` ;
5353
5454 return fn ;
@@ -59,13 +59,13 @@ export function Range(min: number, max: number): FlagTypeFunction<number> {
5959 *
6060 * @param pattern - The regular expression pattern to validate against
6161 * @param description - Optional description for display purposes
62- * @returns A FlagTypeFunction that validates the input value
62+ * @returns A TypeFunction that validates the input value
6363 * @throws {Error } If the value does not match the regex pattern
6464 */
6565export function Regex (
6666 pattern : RegExp ,
6767 description ?: string ,
68- ) : FlagTypeFunction < string > {
68+ ) : TypeFunction < string > {
6969 const fn = ( ( value : string ) => {
7070 if ( ! pattern . test ( value ) ) {
7171 throw new Error (
@@ -74,7 +74,7 @@ export function Regex(
7474 }
7575
7676 return value ;
77- } ) as FlagTypeFunction < string > ;
77+ } ) as TypeFunction < string > ;
7878 fn . display = description ?? pattern . toString ( ) ;
7979
8080 return fn ;
0 commit comments