Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(middleware-flexible-checksums): use union for new config types #6489

Merged
merged 3 commits into from
Sep 17, 2024

Conversation

trivikr
Copy link
Member

@trivikr trivikr commented Sep 17, 2024

Issue

Missed in #6470

Description

Use union for new config types requestChecksumCalculation and responseChecksumValidation

Testing

CI


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

if (!(key in obj)) return undefined;

const value = obj[key]!.toUpperCase();
if (!Object.values(union).includes(value)) {
throw new TypeError(`Cannot load ${type} '${key}'. Expected one of ${Object.values(union)}, got '${obj[key]}'.`);
}

return value;
return value as U[K];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note to self: the type U[K] is guaranteed by the thrown error. value must be a value of union.

@trivikr trivikr merged commit c43103f into aws:main Sep 17, 2024
4 checks passed
@trivikr trivikr deleted the type-flexchecks branch September 17, 2024 20:30
RanVaknin pushed a commit to RanVaknin/aws-sdk-js-v3 that referenced this pull request Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants