Skip to content

Commit a147146

Browse files
authored
fix(util-waiter): fix waiter validation (#1491)
* correct the validator * adding the changeset file * simplify waiter validation test and update changeset type to patch * fix formatting
1 parent f328508 commit a147146

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

.changeset/eleven-poems-bake.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@smithy/util-waiter": patch
3+
---
4+
5+
fix range validation in waiters

packages/util-waiter/src/utils/validate.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ describe(validateWaiterOptions.name, () => {
5050
}
5151
});
5252

53+
it("should not throw an error with small decimal numbers", () => {
54+
waiterOptions.maxWaitTime = 0.5;
55+
waiterOptions.minDelay = 0.0001;
56+
waiterOptions.maxDelay = 0.4;
57+
validateWaiterOptions(waiterOptions);
58+
});
59+
5360
it("should throw when maxWaitTime is less than 0", () => {
5461
waiterOptions.maxWaitTime = -2;
5562
waiterOptions.minDelay = -1;

packages/util-waiter/src/utils/validate.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import { WaiterOptions } from "../waiter";
77
* @param options - a waiter configuration object
88
*/
99
export const validateWaiterOptions = <Client>(options: WaiterOptions<Client>): void => {
10-
if (options.maxWaitTime < 1) {
10+
if (options.maxWaitTime <= 0) {
1111
throw new Error(`WaiterConfiguration.maxWaitTime must be greater than 0`);
12-
} else if (options.minDelay < 1) {
12+
} else if (options.minDelay <= 0) {
1313
throw new Error(`WaiterConfiguration.minDelay must be greater than 0`);
14-
} else if (options.maxDelay < 1) {
14+
} else if (options.maxDelay <= 0) {
1515
throw new Error(`WaiterConfiguration.maxDelay must be greater than 0`);
1616
} else if (options.maxWaitTime <= options.minDelay) {
1717
throw new Error(

0 commit comments

Comments
 (0)