message

Changes the local message configuration of a schema.

const Schema = v.message<TSchema>(schema, message_);

Generics

Parameters

Explanation

This method overrides the local message configuration of the schema. In practice, it is typically used to specify a single error message for an entire pipeline.

Returns

  • Schema TSchema

Examples

The following examples show how message can be used.

Email schema

Email schema that uses the same error message for the entire pipeline.

const EmailSchema = v.message(
  v.pipe(v.string(), v.trim(), v.nonEmpty(), v.email(), v.maxLength(100)),
  'The email is not in the required format.'
);

The following APIs can be combined with message.

Schemas

Methods

Actions

Utils

Async

Contributors

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

  • GitHub profile picture of @fabian-hiller
  • GitHub profile picture of @sacrosanctic

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 @UniquePixels
  • GitHub profile picture of @jdgamble555
  • GitHub profile picture of @nickytonline
  • GitHub profile picture of @KubaJastrz
  • GitHub profile picture of @andrewmd5
  • GitHub profile picture of @caegdeveloper
  • GitHub profile picture of @dslatkin
  • GitHub profile picture of @BrianCurliss