(error: ErrorObject)
| 52 | }; |
| 53 | |
| 54 | export const getControlPath = (error: ErrorObject) => { |
| 55 | // Up until AJV v7 the path property was called 'dataPath' |
| 56 | // With AJV v8 the property was renamed to 'instancePath' |
| 57 | let controlPath = (error as any).dataPath || error.instancePath || ''; |
| 58 | |
| 59 | // change '/' chars to '.' |
| 60 | controlPath = controlPath.replace(/\//g, '.'); |
| 61 | |
| 62 | const invalidProperty = getInvalidProperty(error); |
| 63 | if (invalidProperty !== undefined) { |
| 64 | controlPath = `${controlPath}.${invalidProperty}`; |
| 65 | } |
| 66 | |
| 67 | // remove '.' chars at the beginning of paths |
| 68 | controlPath = controlPath.replace(/^\./, ''); |
| 69 | |
| 70 | // decode JSON Pointer escape sequences |
| 71 | controlPath = decode(controlPath); |
| 72 | return controlPath; |
| 73 | }; |
| 74 | |
| 75 | export const errorsAt = |
| 76 | ( |
no test coverage detected
searching dependent graphs…