From 25af09ad065e72768bf88bc8b529b68f2ca4da17 Mon Sep 17 00:00:00 2001 From: Ashot Nazaryan Date: Tue, 3 Oct 2023 12:07:12 -0700 Subject: [PATCH] fix(typebox): Allow default value in StringEnum (#3281) --- packages/typebox/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/typebox/src/index.ts b/packages/typebox/src/index.ts index 2f338703c4..f6b5f8e2cc 100644 --- a/packages/typebox/src/index.ts +++ b/packages/typebox/src/index.ts @@ -49,8 +49,8 @@ export const getDataValidator = (def: TObject | TDataSchemaMap, validator: Ajv): * @param allowedValues array of strings for the enum * @returns TypeBox.Type */ -export function StringEnum(allowedValues: [...T]) { - return Type.Unsafe({ type: 'string', enum: allowedValues }) +export function StringEnum(allowedValues: [...T], options?: { default: T[number] }) { + return Type.Unsafe({ type: 'string', enum: allowedValues, ...options }) } const arrayOfKeys = (type: T) => {