in authui-container/common/validator.ts [335:361]
private validateRequired(obj: any, components: string[], path: string) {
if (!components.length) {
return;
}
const component = components[0];
if (component === '*') {
const allKeys = Object.keys(obj);
if (!allKeys.length) {
throw new Error(`Missing required field "${path}"`);
}
for (const key of allKeys) {
this.validateRequired(obj[key], components.slice(1), path);
}
} else if (component.substring(component.length - 2) === '[]') {
const prefixKey = component.substring(0, component.length - 2);
if (!isArray(obj[prefixKey])) {
throw new Error(`Missing required field "${path}"`);
}
for (const entry of obj[prefixKey]) {
this.validateRequired(entry, components.slice(1), path);
}
} else if (obj.hasOwnProperty(component)) {
this.validateRequired(obj[component], components.slice(1), path);
} else {
throw new Error(`Missing required field "${path}"`);
}
}