check

Creates a check validation action.

const Action = v.check<TInput, TMessage>(requirement, message);

Generics

Parameters

  • requirement (input: TInput) => boolean
  • message TMessage

Explanation

With check you can freely validate the input and return true if it is valid or false otherwise. If the input does not match your requirement, you can use message to customize the error message.

Returns

Examples

The following examples show how check can be used.

Check object properties

Schema to check the properties of an object.

const CustomObjectSchema = v.pipe(
  v.object({
    list: v.array(v.string()),
    length: v.number(),
  }),
  v.check(
    (input) => input.list.length === input.length,
    'The list does not match the length.'
  )
);

The following APIs can be combined with check.

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