# strictObject

> This document is the Markdown version of [valibot.dev/api/strictObject/](https://valibot.dev/api/strictObject/). For the complete documentation index, see [llms.txt](https://valibot.dev/llms.txt).

Creates a strict object schema.

```ts
const Schema = v.strictObject<TEntries, TMessage>(entries, message);
```

## Generics

- `TEntries` `extends ObjectEntries`
- `TMessage` `extends ErrorMessage<StrictObjectIssue> | undefined`

## Parameters

- `entries` `TEntries`
- `message` `TMessage`

### Explanation

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

> The difference to [`object`](/api/object.md) is that this schema returns an issue for unknown entries. It intentionally returns only one issue. Otherwise, attackers could send large objects to exhaust device resources. If you want an issue for every unknown key, use the [`objectWithRest`](/api/objectWithRest.md) schema with [`never`](/api/never.md) for the `rest` argument.

## Returns

- `Schema` `StrictObjectSchema<TEntries, TMessage>`

## Examples

The following examples show how `strictObject` can be used. Please see the [object guide](/guides/objects.md) for more examples and explanations.

### Simple object schema

Schema to validate a strict object with two keys.

```ts
const SimpleObjectSchema = v.strictObject({
  key1: v.string(),
  key2: v.number(),
});
```

### Merge several objects

Schema that merges the entries of two object schemas.

```ts
const MergedObjectSchema = v.strictObject({
  ...ObjectSchema1.entries,
  ...ObjectSchema2.entries,
});
```

### Mark keys as optional

Schema to validate an object with partial entries.

```ts
const PartialObjectSchema = v.partial(
  v.strictObject({
    key1: v.string(),
    key2: v.number(),
  })
);
```

### Object with selected entries

Schema to validate only selected entries of a strict object.

```ts
const PickObjectSchema = v.pick(
  v.strictObject({
    key1: v.string(),
    key2: v.number(),
    key3: v.boolean(),
  }),
  ['key1', 'key3']
);
```

## Related

The following APIs can be combined with `strictObject`.

### Schemas

[`any`](/api/any.md), [`array`](/api/array.md), [`bigint`](/api/bigint.md), [`blob`](/api/blob.md), [`boolean`](/api/boolean.md), [`custom`](/api/custom.md), [`date`](/api/date.md), [`enum`](/api/enum.md), [`exactOptional`](/api/exactOptional.md), [`file`](/api/file.md), [`function`](/api/function.md), [`instance`](/api/instance.md), [`intersect`](/api/intersect.md), [`lazy`](/api/lazy.md), [`literal`](/api/literal.md), [`looseObject`](/api/looseObject.md), [`looseTuple`](/api/looseTuple.md), [`map`](/api/map.md), [`nan`](/api/nan.md), [`never`](/api/never.md), [`nonNullable`](/api/nonNullable.md), [`nonNullish`](/api/nonNullish.md), [`nonOptional`](/api/nonOptional.md), [`null`](/api/null.md), [`nullable`](/api/nullable.md), [`nullish`](/api/nullish.md), [`number`](/api/number.md), [`object`](/api/object.md), [`objectWithRest`](/api/objectWithRest.md), [`optional`](/api/optional.md), [`picklist`](/api/picklist.md), [`promise`](/api/promise.md), [`record`](/api/record.md), [`set`](/api/set.md), [`strictTuple`](/api/strictTuple.md), [`string`](/api/string.md), [`symbol`](/api/symbol.md), [`tuple`](/api/tuple.md), [`tupleWithRest`](/api/tupleWithRest.md), [`undefined`](/api/undefined.md), [`undefinedable`](/api/undefinedable.md), [`union`](/api/union.md), [`unknown`](/api/unknown.md), [`variant`](/api/variant.md), [`void`](/api/void.md)

### Methods

[`assert`](/api/assert.md), [`config`](/api/config.md), [`fallback`](/api/fallback.md), [`forward`](/api/forward.md), [`getDefault`](/api/getDefault.md), [`getDefaults`](/api/getDefaults.md), [`getFallback`](/api/getFallback.md), [`getFallbacks`](/api/getFallbacks.md), [`is`](/api/is.md), [`keyof`](/api/keyof.md), [`message`](/api/message.md), [`omit`](/api/omit.md), [`parse`](/api/parse.md), [`parser`](/api/parser.md), [`partial`](/api/partial.md), [`pick`](/api/pick.md), [`pipe`](/api/pipe.md), [`required`](/api/required.md), [`safeParse`](/api/safeParse.md), [`safeParser`](/api/safeParser.md)

### Actions

[`check`](/api/check.md), [`brand`](/api/brand.md), [`description`](/api/description.md), [`entries`](/api/entries.md), [`flavor`](/api/flavor.md), [`guard`](/api/guard.md), [`maxEntries`](/api/maxEntries.md), [`metadata`](/api/metadata.md), [`minEntries`](/api/minEntries.md), [`notEntries`](/api/notEntries.md), [`partialCheck`](/api/partialCheck.md), [`rawCheck`](/api/rawCheck.md), [`rawTransform`](/api/rawTransform.md), [`readonly`](/api/readonly.md), [`title`](/api/title.md), [`transform`](/api/transform.md)

### Utils

[`entriesFromList`](/api/entriesFromList.md), [`isOfKind`](/api/isOfKind.md), [`isOfType`](/api/isOfType.md)
