Skip to content

Commit

Permalink
fix(config): validation fix for template strings
Browse files Browse the repository at this point in the history
Allow empty strings as default values for env vars used in template
strings. For example, ${someVar || ""}.

Previously, this would lead to a validation error due to joiPrimitive
not permitting empty strings.
  • Loading branch information
thsig committed May 3, 2019
1 parent b353fcd commit 961dd70
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions garden-service/src/config/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ export const enumToArray = Enum => (
Object.values(Enum).filter(k => typeof k === "string") as string[]
)

export const joiPrimitive = () => Joi.alternatives().try(Joi.number(), Joi.string(), Joi.boolean())
.description("Number, string or boolean")
export const joiPrimitive = () => Joi.alternatives().try(
Joi.number(),
Joi.string().allow(""),
Joi.boolean(),
).description("Number, string or boolean")

export const absolutePathRegex = /^\/.*/ // Note: Only checks for the leading slash
// from https://stackoverflow.com/a/12311250/3290965
Expand Down

0 comments on commit 961dd70

Please sign in to comment.