remove joi usage from x-pack (#99401)
* remove unused helper * remove joi usage from Security Solutions Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
4831826bae
commit
d1d741b479
|
@ -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,
|
||||
});
|
||||
};
|
|
@ -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 = <T>(schema: Joi.Schema): RouteValidationFunction<T> => (
|
||||
interface Schema {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
validate: (input: any) => { value: any; error?: Error };
|
||||
}
|
||||
|
||||
export const buildRouteValidation = <T>(schema: Schema): RouteValidationFunction<T> => (
|
||||
payload: T,
|
||||
{ ok, badRequest }
|
||||
) => {
|
||||
|
|
Loading…
Reference in a new issue