Skip to content

assertcheck v1.0.0


assertcheck / assert / hasValue

Function: hasValue()

ts
function hasValue<T, K>(
   obj, 
   key, 
   expected, 
   opts?): void;

Defined in: src/assert.ts:1616

Asserts that obj[key] === expected (deep equality via _.isEqual). The value type is inferred from T[K].

Type Parameters

Type Parameter
T extends object
K extends string | number | symbol

Parameters

ParameterType
objT
keyK
expectedT[K]
opts?Opts

Returns

void

Example

ts
`assert.hasValue(config, "port", 5432, "wrong database port")`

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