(obj, path = '')
| 11 | }; |
| 12 | |
| 13 | const validateRequiredRecursive = (obj, path = '') => { |
| 14 | if (!isObject(obj)) return []; |
| 15 | let errors = []; |
| 16 | if ('properties' in obj && 'required' in obj) { |
| 17 | assert.isArray(obj.required); |
| 18 | for (const requiredName of obj.required) { |
| 19 | if (!obj.properties[requiredName]) { |
| 20 | errors.push(`${path && path + '.'}properties.${requiredName}`); |
| 21 | } |
| 22 | } |
| 23 | } |
| 24 | for (const property in obj) { |
| 25 | const errorsRecursive = validateRequiredRecursive( |
| 26 | obj[property], |
| 27 | `${path && path + '.'}${property}` |
| 28 | ); |
| 29 | errors = [...errors, ...errorsRecursive]; |
| 30 | } |
| 31 | return errors; |
| 32 | }; |
| 33 | |
| 34 | for (const schemaName of Object.keys(schemas)) { |
| 35 | describe(`${schemaName} schema`, () => { |
no test coverage detected