You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This code is on sandbox. We noticed this behaviour in v3.22.2.
constschema=zod.object({inactiveObject: zod.object({isInactive: zod.boolean(),}).refine(({ isInactive })=>isInactive===false,// <-- This refine fails leading to the preprocess below to be ignored{message: 'object is inactive'}),arr: zod.preprocess((val)=>[val],zod.array(zod.object({}))),// <-- The result of this code is ignored, `arr` remains `val` in the refine below}).refine(({ arr })=>arr.some((elem)=>elem!==null));// arr.some is not a functionschema.safeParse({inactiveObject: {isInactive: true,},arr: {},});
I debugged the code and it turns out the bug occurs here:
-- the result of transform is ignored. This condition was absent in v.3.21.4 which worked fine for the usecase above.
The text was updated successfully, but these errors were encountered:
azhiv
changed the title
The result of zod.preprocess v3.22.4 is ignored and falls back to the original value
The result of zod.preprocess v3.22.4 is ignored and falls back to the original value inside a further refine
Aug 21, 2023
azhiv
changed the title
The result of zod.preprocess v3.22.4 is ignored and falls back to the original value inside a further refine
The result of zod.preprocess v3.22.2 is ignored and falls back to the original value inside a further refine
Aug 21, 2023
This code is on sandbox. We noticed this behaviour in v3.22.2.
I debugged the code and it turns out the bug occurs here:
-- the result of
transform
is ignored. This condition was absent in v.3.21.4 which worked fine for the usecase above.The text was updated successfully, but these errors were encountered: