MCPcopy
hub / github.com/fastify/fastify / wrapValidationError

Function wrapValidationError

lib/validation.js:247–261  ·  view source on GitHub ↗
(result, dataVar, schemaErrorFormatter)

Source from the content-addressed store, hash-verified

245}
246
247function wrapValidationError (result, dataVar, schemaErrorFormatter) {
248 if (result instanceof Error) {
249 result.statusCode = result.statusCode || 400
250 result.code = result.code || 'FST_ERR_VALIDATION'
251 result.validationContext = result.validationContext || dataVar
252 return result
253 }
254
255 const error = schemaErrorFormatter(result, dataVar)
256 error.statusCode = error.statusCode || 400
257 error.code = error.code || 'FST_ERR_VALIDATION'
258 error.validation = result
259 error.validationContext = dataVar
260 return error
261}
262
263module.exports = {
264 symbols: { bodySchema, querystringSchema, responseSchema, paramsSchema, headersSchema },

Callers 5

validateFunction · 0.85
validateAsyncParamsFunction · 0.85
validateAsyncBodyFunction · 0.85
validateAsyncQueryFunction · 0.85
validateAsyncHeadersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected