omit

Creates a modified copy of an object schema that does not contain the selected entries.

const Schema = v.omit<TSchema, TKeys>(schema, keys);

Generics

Parameters

  • schema TSchema
  • keys TKey

Explanation

omit creates a modified copy of the given object schema that does not contain the selected keys. It is similar to TypeScript's Omit utility type.

Because omit changes the data type of the input and output, it is not allowed to pass a schema that has been modified by the pipe method, as this may cause runtime errors. Please use the pipe method after you have modified the schema with omit.

Returns

  • Schema SchemaWithOmit<TSchema, TKeys>

Examples

The following examples show how omit can be used.

Omit specific keys

Schema that does not contain the selected keys of an existing schema.

const OmittedSchema = v.omit(
  v.object({
    key1: v.string(),
    key2: v.number(),
    key3: v.boolean(),
  }),
  ['key1', 'key3']
); // { key2: number }

The following APIs can be combined with omit.

Schemas

Methods

Actions

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