Creates an object schema.

const Schema = object<TEntries, TMessage>(entries, message);



  • entries TEntries
  • message TMessage


With object you can validate the data type of the input and whether the content matches entries. If the input is not an object, you can use message to customize the error message.

This schema removes unknown entries. The output will only include the entries you specify. To include unknown entries, use looseObject. To return an issue for unknown entries, use strictObject. To include and validate unknown entries, use objectWithRest.



The following examples show how object can be used. Please see the object guide for more examples and explanations.

Simple object schema

Schema to validate an object with two keys.

const SimpleObjectSchema = v.object({
  key1: v.string(),
  key2: v.number(),

Merge several objects

Schema that merges the entries of two object schemas.

const MergedObjectSchema = v.object({

Mark keys as optional

Schema to validate an object with partial entries.

const PartialObjectSchema = v.partial(
    key1: v.string(),
    key2: v.number(),

Object with selected entries

Schema to validate only selected entries of an object.

const PickObjectSchema = v.pick(
    key1: v.string(),
    key2: v.number(),
    key3: v.boolean(),
  ['key1', 'key3']

The following APIs can be combined with object.





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

  • GitHub profile picture of fabian-hiller
  • GitHub profile picture of kazizi55


Thanks to our partners who support the project ideally and financially.


Thanks to our GitHub sponsors who support the project financially.

  • GitHub profile picture of dailydotdev
  • GitHub profile picture of KATT
  • GitHub profile picture of osdiab
  • GitHub profile picture of Thanaen
  • GitHub profile picture of ruiaraujo012
  • GitHub profile picture of hyunbinseo
  • GitHub profile picture of caegdeveloper
  • GitHub profile picture of seahindeniz