config

Changes the local configuration of a schema.

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

Generics

Parameters

Explanation

This method overwrites the selected configuration properties by merging the previous configuration of the schema with the provided config.

Returns

  • Schema TSchema

Examples

The following examples show how config can be used.

Same error message

Schema that uses the same error message for the entire pipeline.

const Schema = v.object({
  email: v.config(
    v.pipe(v.string(), v.trim(), v.email(), v.endsWith('@example.com')),
    { message: 'The email does not conform to the required format.' }
  ),
  // ...
});

Abort pipeline early

Schema that aborts only a specific pipeline early.

const Schema = v.object({
  url: v.config(
    v.pipe(v.string(), v.trim(), v.url(), v.endsWith('@example.com')),
    { abortPipeEarly: true }
  ),
  // ...
});

The following APIs can be combined with config.

Schemas

Methods

Actions

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 dailydotdev
  • GitHub profile picture of Thanaen
  • GitHub profile picture of KATT
  • GitHub profile picture of osdiab
  • GitHub profile picture of ruiaraujo012
  • GitHub profile picture of hyunbinseo
  • GitHub profile picture of F0rce
  • GitHub profile picture of caegdeveloper
  • GitHub profile picture of seahindeniz