intersect

Creates an intersect schema.

I recommend to read the intersections guide before using this schema function.

const Schema = v.intersect<TOptions, TMessage>(options, message);

Generics

Parameters

  • options TOptions
  • message TMessage

Explanation

With intersect you can validate if the input matches each of the given options. If the output of the intersection cannot be successfully merged, you can use message to customize the error message.

Returns

Examples

The following examples show how intersect can be used.

Object intersection

Schema that combines two object schemas.

const ObjectSchema = v.intersect([
  v.object({ foo: v.string() }),
  v.object({ bar: v.number() }),
]);

The following APIs can be combined with intersect.

Schemas

Methods

Actions

Utils

Contributors

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

  • GitHub profile picture of fabian-hiller
  • GitHub profile picture of morinokami
  • GitHub profile picture of EltonLobo07

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 andrew-3kb
  • GitHub profile picture of dslatkin