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:
Mikhail Shustov 2021-05-11 10:04:30 +02:00 committed by GitHub
parent 4831826bae
commit d1d741b479
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 25 deletions

View file

@ -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,
});
};

View file

@ -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 }
) => {