pl-api: make coerceObject not accept arrays

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
nicole mikołajczyk
2026-03-18 16:32:42 +01:00
parent 77855b133f
commit c2c6846f98
2 changed files with 6 additions and 2 deletions

View File

@ -19,7 +19,9 @@ const coerceObject = <T extends v.ObjectEntries>(shape: T) =>
v.optional(
v.pipe(
v.any(),
v.transform((input) => (typeof input === 'object' && input !== null ? input : {})),
v.transform((input) =>
typeof input === 'object' && !Array.isArray(input) && input !== null ? input : {},
),
v.object(shape),
),
{},

View File

@ -40,7 +40,9 @@ const coerceObject = <T extends v.ObjectEntries>(shape: T) =>
v.optional(
v.pipe(
v.any(),
v.transform((input) => (typeof input === 'object' && input !== null ? input : {})),
v.transform((input) =>
typeof input === 'object' && !Array.isArray(input) && input !== null ? input : {},
),
v.object(shape),
),
{},