* Strictly validate the data according to the endpoint schema. * This rejects unknown/invalid keys. * Optionally it prints those keys in the message to provide detailed feedback. * * @param {object} data Object containing the data for validation * @param {object} attrs Refer to individual attri
(
data,
{ prettyErrorMessage = 'invalid response data', includeKeys = false } = {},
)
| 63 | * @returns {object} Value if Joi validation is success |
| 64 | */ |
| 65 | function validateEndpointData( |
| 66 | data, |
| 67 | { prettyErrorMessage = 'invalid response data', includeKeys = false } = {}, |
| 68 | ) { |
| 69 | return validate( |
| 70 | { |
| 71 | ErrorClass: InvalidResponse, |
| 72 | prettyErrorMessage, |
| 73 | includeKeys, |
| 74 | traceErrorMessage: 'Response did not match schema', |
| 75 | traceSuccessMessage: 'Response after validation', |
| 76 | allowAndStripUnknownKeys: false, |
| 77 | }, |
| 78 | data, |
| 79 | endpointSchema, |
| 80 | ) |
| 81 | } |
| 82 | |
| 83 | const anySchema = Joi.any() |
| 84 |
no test coverage detected