Skip to content

Commit

Permalink
Create explicit boolean helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
kamarmack committed Nov 12, 2024
1 parent 878ceba commit 0c472a9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions typescript-api-helpers/yup-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@ export const YupHelpers = {
.meta({ type: GeneralizedFieldTypeEnum.obj.list }),
constant: <T extends boolean | string | number>(value: T) =>
yup.mixed<T>().oneOf([value]).default(value),
booleanDefaultFalse: () =>
yup
.boolean()
.default(false)
.meta({ type: GeneralizedFieldTypeEnum.obj.boolean }),
booleanDefaultTrue: () =>
yup
.boolean()
.default(true)
.meta({ type: GeneralizedFieldTypeEnum.obj.boolean }),
booleanDefaultUnset: () =>
yup
.boolean()
.nullable()
.default(null)
.meta({ type: GeneralizedFieldTypeEnum.obj.boolean }),
date: () =>
yup
.string()
Expand Down

0 comments on commit 0c472a9

Please sign in to comment.