Skip to content

Commit

Permalink
fix(typebox): Allow default value in StringEnum (#3281)
Browse files Browse the repository at this point in the history
  • Loading branch information
AshotN authored Oct 3, 2023
1 parent 64ee98d commit 25af09a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/typebox/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends string[]>(allowedValues: [...T]) {
return Type.Unsafe<T[number]>({ type: 'string', enum: allowedValues })
export function StringEnum<T extends string[]>(allowedValues: [...T], options?: { default: T[number] }) {
return Type.Unsafe<T[number]>({ type: 'string', enum: allowedValues, ...options })
}

const arrayOfKeys = <T extends TObject>(type: T) => {
Expand Down

0 comments on commit 25af09a

Please sign in to comment.