From 3239cda9880d0cd2380ade39c6d7096b8199c432 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Fri, 1 Mar 2024 10:43:10 +0100 Subject: [PATCH] Fix tests --- src/structs/types.ts | 4 ++-- src/utils.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/structs/types.ts b/src/structs/types.ts index 24000bf7..ba930abf 100644 --- a/src/structs/types.ts +++ b/src/structs/types.ts @@ -690,8 +690,8 @@ export function union( type: 'union', schema: null, coercer(value) { - for (const { validate } of Structs) { - const [error, coerced] = validate(value, { coerce: true }); + for (const InnerStruct of Structs) { + const [error, coerced] = InnerStruct.validate(value, { coerce: true }); if (!error) { return coerced; } diff --git a/src/utils.ts b/src/utils.ts index 305ae71d..282a0e74 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -199,7 +199,8 @@ export function* run( yield [failure, undefined]; } - for (const [innerKey, innerValue, innerStruct] of struct.entries( + // eslint-disable-next-line prefer-const + for (let [innerKey, innerValue, innerStruct] of struct.entries( value, context, )) { @@ -220,8 +221,7 @@ export function* run( yield [result[0], undefined]; } else if (coerce) { - // eslint-disable-next-line no-param-reassign - value = result[1]; + innerValue = result[1]; if (innerKey === undefined) { // eslint-disable-next-line no-param-reassign