* @param {*} schema * @return {*}
(schema)
| 80 | * @return {*} |
| 81 | */ |
| 82 | function addCustomValidatorsToSchema(schema) { |
| 83 | if (typeof schema !== 'object') { |
| 84 | return schema; |
| 85 | } |
| 86 | if (Array.isArray(schema)) { |
| 87 | return schema.map(addCustomValidatorsToSchema); |
| 88 | } |
| 89 | for (const {fn, shouldUse} of customValidators) { |
| 90 | if (shouldUse(schema)) { |
| 91 | schema[`_${fn}`] = true; |
| 92 | } |
| 93 | } |
| 94 | for (const k in schema) { |
| 95 | schema[k] = addCustomValidatorsToSchema(schema[k]); |
| 96 | } |
| 97 | return schema; |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Remaps `ajv-formats` in order to only use simple formats (true, string, RegExp). |
no test coverage detected