Skip to content

hap-fluent / isCharacteristicValue

Function: isCharacteristicValue() ​

ts
function isCharacteristicValue(value): value is CharacteristicValue;

Defined in: packages/hap-fluent/src/type-guards.ts:36

Determine whether value is a valid HAP CharacteristicValue.

Parameters ​

ParameterTypeDescription
valueunknownValue to test.

Returns ​

value is CharacteristicValue

true if value is a string, number, boolean, or non-null object.

Remarks ​

The HAP specification defines valid characteristic value types as: string, number, boolean, or object. null and undefined are not valid — @homebridge/hap-nodejs will throw if you attempt to set them.

Example ​

typescript
isCharacteristicValue(true);   // true
isCharacteristicValue(75);     // true
isCharacteristicValue(null);   // false
isCharacteristicValue(undefined); // false

Released under the Apache-2.0 License.