joi_1.default.validate is not a function : <p>I want to validate my Express routes before calling the controller logic. I use joi and created a validator which is able to validate the Request object against the schema object</p>

<pre><code>import { Request, Response, NextFunction } from 'express';
import joi, { SchemaLike, ValidationError, ValidationResult } from '@hapi/joi';
import { injectable } from 'inversify';

@injectable()
export abstract class RequestValidator {
    protected validateRequest = (validationSchema: SchemaLike, request: Request, response: Response, next: NextFunction): void =&gt; {
        const validationResult: ValidationResult&lt;Request&gt; = joi.validate(request, validationSchema, {
            abortEarly: false
        });

        const { error }: { error: ValidationError } = validationResult;

        if (error) {
            response.status(400).json({
                message: 'The request validation failed.',
                details: error.details
            });
        } else {
            next();
        }
    }
}
</code></pre>

<p>Next I created a deriving class which creates the validationSchema and calls the <code>validateRequest</code> method. For the sake of simplicity I will show the "deleteUserById" validation</p>

<pre><code>import { Request, Response, NextFunction } from 'express';
import joi, { SchemaLike } from '@hapi/joi';
import { injectable } from 'inversify';

import { RequestValidator } from './RequestValidator';

@injectable()
export class UserRequestValidator extends RequestValidator {
    public deleteUserByIdValidation = async (request: Request, response: Response, next: NextFunction): Promise&lt;void&gt; =&gt; {
        const validationSchema: SchemaLike = joi.object().keys({
            params: joi.object().keys({
                id: joi.number().required(),
            })
        });

        this.validateRequest(validationSchema, request, response, next);
    }
}
</code></pre>

<p><strong>Important note:</strong> I create the <code>SchemaLike</code> that way because some routes might have <code>params, body, query</code> which need to get validated in one run. </p>

<p>When calling the Route </p>

<blockquote>
  <p>DELETE /users/1</p>
</blockquote>

<p>the validation always fails. I get this error</p>

<blockquote>
  <p>UnhandledPromiseRejectionWarning: TypeError: joi_1.default.validate is
  not a function</p>
</blockquote>

<p>The error occurs with every validation, whether called correctly or not. Does someone know how to fix it?</p>
