2024-04-05 13:16:49 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
2024-03-02 17:29:18 +02:00
|
|
|
export const objectValueFromPath = (o: any, path: string) => {
|
|
|
|
const elements = path.split('.');
|
|
|
|
let result = { ...o };
|
|
|
|
while (elements.length && result) {
|
|
|
|
const e = elements.splice(0, 1)[0];
|
|
|
|
result = result[e];
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
};
|
2024-03-02 16:25:27 +02:00
|
|
|
|
2024-04-05 13:16:49 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
2024-03-02 16:25:27 +02:00
|
|
|
export function checkObjectHasProperties(object: any, properties: string[]) {
|
|
|
|
for (const prop of properties) {
|
|
|
|
if (!(prop in object)) throw new Error(`Missing property "${prop}": ${JSON.stringify(object)}`);
|
|
|
|
}
|
|
|
|
}
|