MCPcopy
hub / github.com/badges/shields / validateEndpointData

Function validateEndpointData

services/endpoint-common.js:65–81  ·  view source on GitHub ↗

* 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 } = {},
)

Source from the content-addressed store, hash-verified

63 * @returns {object} Value if Joi validation is success
64 */
65function 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
83const anySchema = Joi.any()
84

Callers 1

fetchEndpointDataFunction · 0.85

Calls 1

validateFunction · 0.50

Tested by

no test coverage detected