Skip to content

Commit

Permalink
Parsing a string from env var to boolean is messed up in zod
Browse files Browse the repository at this point in the history
  • Loading branch information
iainsproat committed Dec 6, 2024
1 parent a06bc1c commit b3ae082
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/shared/src/environment/multiRegionConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ const regionConfigSchema = regionConfigSchemaV1.extend({
accessKey: z.string(),
secretKey: z.string(),
bucket: z.string(),
createBucketIfNotExists: z.coerce.boolean(),
createBucketIfNotExists: z.preprocess((val) => {
if (typeof val === 'string') {
if (['1', 'true'].includes(val.toLowerCase())) return true
if (['0', 'false'].includes(val.toLowerCase())) return false
}
return false
}, z.coerce.boolean()),
s3Region: z.string()
})
})
Expand Down

0 comments on commit b3ae082

Please sign in to comment.