Skip to content

Commit 8bfd2d6

Browse files
committed
Add validation
1 parent 7110b67 commit 8bfd2d6

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

packages/aws-cdk-lib/aws-lambda/lib/function.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,9 @@ export class Function extends FunctionBase {
10851085
* function and undefined if not.
10861086
*/
10871087
private getLoggingConfig(props: FunctionProps): CfnFunction.LoggingConfigProperty | undefined {
1088+
if (props.logFormat !== undefined && !Object.values(LogFormat).includes(props.logFormat as LogFormat)) {
1089+
throw new TypeError(`'${props.logFormat}' is not a legal LogFormat type.`);
1090+
}
10881091
if ((props.applicationLogLevel || props.systemLogLevel) && props.logFormat !== LogFormat.JSON) {
10891092
throw new Error(`To use ApplicationLogLevel and/or SystemLogLevel you must set LogFormat to '${LogFormat.JSON}', got '${props.logFormat}'.`);
10901093
}

0 commit comments

Comments
 (0)