openapi-fastify
    Preparing search index...

    Type Alias AutoValidateRequestResponseConfig

    AutoValidateRequestResponseConfig:
        | boolean
        | {
            errorResponse?: {
                payload: | Record<string, any>
                | ((errors: ErrorObject<any>[]) => Record<string, any>);
                status: number;
            };
            onError?: (
                request: FastifyRequest,
                reply: FastifyReply,
                errors?: ErrorObject<any>[],
            ) => FastifyReply | undefined;
            validate?: boolean;
        }

    Type Declaration

    • boolean
    • {
          errorResponse?: {
              payload:
                  | Record<string, any>
                  | ((errors: ErrorObject<any>[]) => Record<string, any>);
              status: number;
          };
          onError?: (
              request: FastifyRequest,
              reply: FastifyReply,
              errors?: ErrorObject<any>[],
          ) => FastifyReply | undefined;
          validate?: boolean;
      }
      • OptionalerrorResponse?: {
            payload:
                | Record<string, any>
                | ((errors: ErrorObject<any>[]) => Record<string, any>);
            status: number;
        }

        use onError instead

      • OptionalonError?: (
            request: FastifyRequest,
            reply: FastifyReply,
            errors?: ErrorObject<any>[],
        ) => FastifyReply | undefined
        • A function that is called when an error occurs during validation.
        • If not provided, the default error response will be used.
        {status: 400, payload: {error: "Invalid Request Body", errors: Ajv.Errors[]}}
        
        (request, reply, errors) => {
        return reply.status(400).send({ error: "Invalid Request Body", errors });
        }
      • Optionalvalidate?: boolean