The union of property keys represented by the record.
The value type that each property must satisfy.
true if all entries satisfy the predicate, otherwise false.
This function validates both the property keys and values of an object using a custom predicate callback.
By default, only enumerable string keys are checked using Object.keys().
When includeHidden is enabled, all own property keys are inspected
using Reflect.ownKeys(), including:
The predicate receives:
and must return whether the value satisfies the expected type.
Validate a record of strings:
isRecordOf(
{ a: 'hello', b: 'world' },
(_k, v): v is string => isString(v)
); // true
Validate key-sensitive values:
isRecordOf(
{ port: 3000 },
(k, v): v is number => {
return k === 'port' && isNumber(v);
}
);
Include non-enumerable and symbol keys:
const obj = Object.defineProperty(
{ [Symbol('id')]: 123 },
'hidden',
{
value: 456,
enumerable: false,
}
);
isRecordOf(obj, (_k, v): v is number => {
return isNumber(v);
}, true);
Determines whether the provided value is a record whose entries satisfy the given predicate.