Skip to content

Commit

Permalink
fixed serverSdkVersion validation
Browse files Browse the repository at this point in the history
  • Loading branch information
lpizzinidev committed Nov 7, 2023
1 parent 9ff0d08 commit 640044b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-gamelift-alpha/lib/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,12 @@ export class Build extends BuildBase {
}

private validateServerSdkVersion(serverSdkVersion?: string) {
if (!serverSdkVersion) return;
if (serverSdkVersion === undefined || cdk.Token.isUnresolved(serverSdkVersion)) return;
if (!serverSdkVersion.match(/^\d+\.\d+\.\d+$/)) {
throw new Error(`serverSdkVersion must be in the 0.0.0 format, got ${serverSdkVersion}.`);
throw new Error(`serverSdkVersion must be in the 0.0.0 format, got \'${serverSdkVersion}\'.`);
}
if (serverSdkVersion.length > 128) {
throw new Error(`serverSdkVersion length must be smaller than or equal to 128, got ${serverSdkVersion}.`);
throw new Error(`serverSdkVersion length must be smaller than or equal to 128, got ${serverSdkVersion.length}.`);
}
}
}
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-gamelift-alpha/test/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,14 @@ describe('build', () => {
expect(() => new gamelift.Build(stack, 'BuildWithInvalidServerSdkVersion', {
content,
serverSdkVersion: 'invalid',
})).toThrow(/serverSdkVersion must be in the 0.0.0 format, got invalid./);
})).toThrow(/serverSdkVersion must be in the 0.0.0 format, got 'invalid'./);
});

test('with an incorrect serverSdkVersion length', () => {
expect(() => new gamelift.Build(stack, 'BuildWithInvalidServerSdkVersion', {
content,
serverSdkVersion: '1'.repeat(50) + '.' + '1'.repeat(50) + '.' + '1'.repeat(50),
})).toThrow(/serverSdkVersion length must be smaller than or equal to 128/);
})).toThrow(/serverSdkVersion length must be smaller than or equal to 128, got 152./);
});
});
});
Expand Down

0 comments on commit 640044b

Please sign in to comment.