Skip to content

Commit 849ebfe

Browse files
committed
Incorporate explanation from @colinhacks into message doc comment
1 parent c2750a0 commit 849ebfe

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/ZodError.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,10 @@ export class ZodError<T = any> extends Error {
285285
}
286286

287287
/**
288-
* message returns the .issues field as a pretty-printed JSON string, NOT necessarily a human-readable message.
288+
* message is a JSON.stringified issues array. This is an intentional decision
289+
* to make the message property as informative as possible for logging, etc.
290+
* You should use .issues to retrieve granular error information rather than
291+
* JSON.parse(err.message).
289292
*/
290293
override get message() {
291294
return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);

0 commit comments

Comments
 (0)