Skip to content

assertcheck v1.0.0


assertcheck / assert / hasExactKeys

Function: hasExactKeys() ​

ts
function hasExactKeys<K>(
   obj, 
   keys, 
   opts?): asserts obj is Record<K, unknown>;

Defined in: src/assert.ts:1549

Asserts that obj has exactly the given keys — no more, no less. Narrows the type to Record<K, unknown> after the call.

Type Parameters ​

Type Parameter
K extends string

Parameters ​

ParameterType
objobject
keysK[]
opts?Opts

Returns ​

asserts obj is Record<K, unknown>

Example ​

ts
`assert.hasExactKeys(payload, ["id","name","email"])`

Released under the Apache 2.0 License. Built by Vagabond Studio — senior-only for growing companies.