Asserts that an object has the specified properties with the specified types. Ideal for quick runtime type checking
of API responses if you don't need a full schema validation.
Example
constvalidated = assertProps(obj, { id:"string", age:"number" }); // obj is runtime validated and type is now narrowed down to { id: string; age: number } // if the assertion fails, an error is thrown console.log(obj.id, obj.age);
Asserts that an object has the specified properties with the specified types. Ideal for quick runtime type checking of API responses if you don't need a full schema validation.
Example