const myType = ((val: string | undefined, varname: string) => {
if (!val) {
if (def === REQUIRED) {
return `::ERROR::${varname}::This value is required`;
}
return def;
}
try {
// Normally you would validate but for testing we're skipping that and just returning whatever
return JSON.parse(val) as MyType;
} catch (e: any) {
return `::ERROR::${varname}::Invalid JSON string passed: ${e.message}`;
}
}) as TransformerFunction<MyType>;
// ...
const configDef = {
myType: configValue('MY_TYPE', myType, REQUIRED),
// ...
}
Generated using TypeDoc
Any function conforming to this interface may be passed to the
configValue
function to transform the value of a given config key.