summarize
Summarize the error messages of issues in a pretty-printable multi-line string.
const errors = v.summarize(issues);
Parameters
issues[BaseIssue<unknown>, ...BaseIssue<unknown>[]]
Explanation
If an issue in issues contains a path that can be converted to a dot path, the dot path will be displayed in the errors output just below the issue's error message.
Returns
errorsstring
Examples
The following example show how summarize can be used.
const Schema = v.object({
nested: v.object({
foo: v.string('Value of "nested.foo" is invalid.'),
}),
});
const result = v.safeParse(Schema, { nested: { foo: null } });
if (result.issues) {
console.log(v.summarize(result.issues));
}
Related
The following APIs can be combined with summarize.
Methods
© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/summarize/