| 85 | * @param {String} namespace String for tracking nested properties |
| 86 | */ |
| 87 | const noEmptyObjectValues = ( |
| 88 | obj: Record<string, unknown>, |
| 89 | namespace = '' |
| 90 | ): string[] => { |
| 91 | const emptyKeys = []; |
| 92 | for (const key of Object.keys(obj)) { |
| 93 | const value = obj[key]; |
| 94 | const field = namespace ? `${namespace}.${key}` : key; |
| 95 | if (Array.isArray(value)) { |
| 96 | if (!value.length) { |
| 97 | emptyKeys.push(field); |
| 98 | } |
| 99 | } else if (typeof value === 'object') { |
| 100 | emptyKeys.push( |
| 101 | noEmptyObjectValues(value as Record<string, unknown>, field) |
| 102 | ); |
| 103 | } else if (!value) { |
| 104 | emptyKeys.push(field); |
| 105 | } |
| 106 | } |
| 107 | return emptyKeys.flat(); |
| 108 | }; |
| 109 | |
| 110 | /** |
| 111 | * Grab the schema keys once, to avoid overhead of |