metadata

Creates a custom metadata action.

const Action = v.metadata<TInput, TMetadata>(metadata_);

Generics

  • TInput extends any
  • TMetadata extends Record<string, unknown>

Parameters

  • metadata_ TMetadata

Explanation

With metadata you can attach custom metadata to a schema. This can be useful when working with AI tools or for documentation purposes.

Returns

Examples

The following examples show how metadata can be used.

Profile table schema

Schema to describe a profile table.

const ProfileTableSchema = v.pipe(
  v.object({
    username: v.pipe(v.string(), v.nonEmpty()),
    email: v.pipe(v.string(), v.email()),
    avatar: v.pipe(v.string(), v.url()),
    description: v.pipe(v.string(), v.maxLength(500)),
  }),
  v.metadata({
    table: 'profiles',
    primaryKey: 'username',
    indexes: ['email'],
  })
);

The following APIs can be combined with metadata.

Schemas

Methods

Utils

Contributors

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

  • GitHub profile picture of fabian-hiller

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 Thanaen
  • GitHub profile picture of osdiab
  • GitHub profile picture of ruiaraujo012
  • GitHub profile picture of hyunbinseo
  • GitHub profile picture of F0rce
  • GitHub profile picture of fabulousgk
  • GitHub profile picture of jdgamble555
  • GitHub profile picture of isoden
  • GitHub profile picture of nickytonline
  • GitHub profile picture of caegdeveloper
  • GitHub profile picture of luckasnix
  • GitHub profile picture of andrew-3kb
  • GitHub profile picture of dslatkin