MVFv3 API Documentation
    Preparing search index...

    Variable SafeStringEnumConst

    SafeStringEnum: <K extends readonly string[]>(
        enumValues: K,
        options?: StringOptions,
    ) => {
        record: Readonly<{ [Key in K[number] | "unknown"]: Key }>;
        schema: ReturnType<typeof SafeStringEnumSchema>;
        values: readonly (K[number] | "unknown")[];
    }

    Utility that both creates a SafeStringEnumSchema and returns it along with the values in a readonly array, and a record of the enum values, with 'unknown' included.

    Used to allow an extension to both define the schema and export the values in a consistent way.

    Type declaration

      • <K extends readonly string[]>(
            enumValues: K,
            options?: StringOptions,
        ): {
            record: Readonly<{ [Key in K[number] | "unknown"]: Key }>;
            schema: ReturnType<typeof SafeStringEnumSchema>;
            values: readonly (K[number] | "unknown")[];
        }
      • Type Parameters

        • K extends readonly string[]

        Parameters

        • enumValues: K
        • Optionaloptions: StringOptions

        Returns {
            record: Readonly<{ [Key in K[number] | "unknown"]: Key }>;
            schema: ReturnType<typeof SafeStringEnumSchema>;
            values: readonly (K[number] | "unknown")[];
        }

    export const MyEnum = createSafeEnum(['a', 'b', 'c'] as const);
    export type MyEnum = Static<typeof MyEnum.schema>;
    // type MyEnum = "a" | "b" | "c" | "unknown"
    export const MY_ENUMS = MyEnum.values;
    // MY_ENUMS = ["a", "b", "c", "unknown"]
    export const MY_ENUM = MyEnum.record;
    // MY_ENUM = { a: "a", b: "b", c: "c", unknown: "unknown" }