isObject
isObjectVerifies if provided Verificable represents a value that is an object. Only non-null values for which typeof operation provides "object" result are matching, so string, number and other primitive values will not match this Predicate.
The check internally is done by checking the type of the value typeof value === "object", however explicitly excluding null as matching value.
That also means that functions are not matching this predicate, since for functions typeof operation returns "function", but arrays are matching the predicate.
Possible errors:
If provided Verificable is not an object:
Verificable is not an object:{
type: "isObject",
path: [/* ... */]
}Examples:
Each of examples uses this import statement:
const { asVerificable, isValid, isObject } = require("verifica");Null or undefined is not considered an object:
const verificable = asVerificable(null);
isValid(verificable, isObject); // falseString value is not considered an object as well:
const verificable = asVerificable("123");
isValid(verificable, isObject); // falseObjects are matching:
const verificable = asVerificable({ prop: "value" });
isValid(verificable, isObject); // trueArrays are considered objects as well:
const verificable = asVerificable(["a", "b"]);
isValid(verificable, isObject); // trueLast updated
Was this helpful?