pl-api: make coerceObject not accept arrays
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -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),
|
||||
),
|
||||
{},
|
||||
|
||||
@ -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),
|
||||
),
|
||||
{},
|
||||
|
||||
Reference in New Issue
Block a user