examples

Creates an examples metadata action.

const Action = v.examples<TInput, TExamples>(examples_);

Generics

  • TInput extends any
  • TExamples extends readonly TInput[]

Parameters

  • examples_ TExamples

Explanation

With examples you can provide examples for a schema. This can be useful when working with AI tools or for documentation purposes.

Returns

Examples

The following examples show how examples can be used.

String schema

Schema to validate a string with examples.

const StringSchema = v.pipe(v.string(), v.examples(['foo', 'bar', 'baz']));

Number schema

Schema to validate a number with examples.

const NumberSchema = v.pipe(v.number(), v.examples([1, 2, 3]));

The following APIs can be combined with examples.

Schemas

Methods

Utils

Contributors

Thanks to all the contributors who helped make this page better!

  • GitHub profile picture of @EskiMojo14

Partners

Thanks to our partners who support the project ideally and financially.

Sponsors

Thanks to our GitHub sponsors who support the project financially.

  • GitHub profile picture of @antfu
  • GitHub profile picture of @vasilii-kovalev
  • GitHub profile picture of @saturnonearth
  • GitHub profile picture of @ruiaraujo012
  • GitHub profile picture of @hyunbinseo
  • GitHub profile picture of @nickytonline
  • GitHub profile picture of @KubaJastrz
  • GitHub profile picture of @andrewmd5
  • GitHub profile picture of @Thanaen
  • GitHub profile picture of @caegdeveloper
  • GitHub profile picture of @bmoyroud
  • GitHub profile picture of @dslatkin