diff --git a/x-pack/plugins/apm/server/lib/helpers/input_validation.ts b/x-pack/plugins/apm/server/lib/helpers/input_validation.ts deleted file mode 100644 index 0a34711b9b40..000000000000 --- a/x-pack/plugins/apm/server/lib/helpers/input_validation.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import Joi, { Schema } from 'joi'; -export const dateValidation = Joi.alternatives() - .try(Joi.date().iso(), Joi.number()) - .required(); - -export const withDefaultValidators = ( - validators: { [key: string]: Schema } = {} -) => { - return Joi.object().keys({ - _inspect: Joi.bool(), - start: dateValidation, - end: dateValidation, - uiFilters: Joi.string(), - ...validators, - }); -}; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/utils.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/utils.ts index 34f40012f00b..959ab89c0122 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/utils.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/utils.ts @@ -6,7 +6,6 @@ */ import Boom from '@hapi/boom'; -import Joi from 'joi'; import { errors } from '@elastic/elasticsearch'; import { has, snakeCase } from 'lodash/fp'; import { SanitizedAlert } from '../../../../../alerting/common'; @@ -233,7 +232,12 @@ export const transformBulkError = ( } }; -export const buildRouteValidation = (schema: Joi.Schema): RouteValidationFunction => ( +interface Schema { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + validate: (input: any) => { value: any; error?: Error }; +} + +export const buildRouteValidation = (schema: Schema): RouteValidationFunction => ( payload: T, { ok, badRequest } ) => {