Skip to content

Commit

Permalink
Allow omitting value
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jan 23, 2022
1 parent 8485a2a commit 723024c
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/config/normalize/lib/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,10 @@ const validateValue = async function (value, validate, opts) {
await callValueFunc(validate, value, opts)
}

// Apply `transform(value)` which transforms the value set by the user
// Apply `transform(value)` which transforms the value set by the user.
// If can also delete it by returning `undefined`.
const transformValue = async function (value, transform, opts) {
if (value === undefined || transform === undefined) {
return value
}

const newValue = await callValueFunc(transform, value, opts)
return newValue === undefined ? value : newValue
return value === undefined || transform === undefined
? value
: await callValueFunc(transform, value, opts)
}

0 comments on commit 723024c

Please sign in to comment.