import * as t from 'io-ts' ; import { pipe } from 'fp-ts/pipeable' ; import { fold } from 'fp-ts/Either' ; import { exactCheck , formatErrors } from '@kbn/securitysolution-io-ts-utils' ; import { DataValidationError } from './errors' ; param validator param data export const validateData = < D > ( validator , data ) : undefined | DataValidationError => { return pipe ( validator . decode ( data ) , ( decoded ) => exactCheck ( data , decoded ) , fold ( ( errors ) => { const errorStrings = formatErrors ( errors ) ; return new DataValidationError ( errorStrings , 400 ) ; } , ( ) => undefined ) ) ; } ;