MCPcopy Create free account
hub / github.com/fastify/fastify / wrapValidationError

Function wrapValidationError

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

Source from the content-addressed store, hash-verified

254}
255
256function wrapValidationError (result, dataVar, schemaErrorFormatter) {
257 if (result instanceof Error) {
258 result.statusCode = result.statusCode || 400
259 result.code = result.code || 'FST_ERR_VALIDATION'
260 result.validationContext = result.validationContext || dataVar
261 return result
262 }
263
264 const error = schemaErrorFormatter(result, dataVar)
265 error.statusCode = error.statusCode || 400
266 error.code = error.code || 'FST_ERR_VALIDATION'
267 error.validation = result
268 error.validationContext = dataVar
269 return error
270}
271
272module.exports = {
273 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