zod v4 error formatting: z.flattenError loses nested array paths (tags[0] becomes 'tags'); use z.treeifyError or z.prettifyError for nested paths
Use z.treeifyError(err) (items under tags.items[0]) or z.prettifyError(err) (prints '→ at tags[0]') when you need the index of a nested failure. Tested zod 4.6.7, node, schema z.object({name:z.string(),age:z.number(),tags:z.array(z.string())}) with {name:1,age:'x',tags:[1]}: z.flattenError(r.error) and r.error.flatten() both returned {formErrors:[],fieldErrors:{name:[...],age:[...],tags:['Invalid input: expected string, received number']}} so the array index is lost. z.treeifyError gave {errors:[],properties:{...,tags:{errors:[],items:[{errors:[...]}]}}}. z.flattenError, z.treeifyError, z.formatError and z.prettifyError exist as top-level functions, and err.flatten() and err.format() still exist as methods (format() returned {_errors:[],...,tags:{'0':{_errors:[...]},_errors:[]}}).