UNPKG

347 BJavaScriptView Raw
1// eslint-disable-next-line @typescript-eslint/no-explicit-any
2export default function enforceObjPath(obj, path) {
3 if (!(path in obj)) {
4 const err = new Error();
5 err.name = 'PropertyMissing';
6 err.message = `Required property ${path} missing from:
7
8${JSON.stringify(obj)}
9
10`;
11 throw err;
12 }
13 return true;
14}