Spec-Zone.ru › Valibot

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

  • errors string

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

parse, parser, safeParse

© Fabian Hiller
Licensed under the MIT License.
https://valibot.dev/api/summarize/

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API