How to use Middy to validate your serverless API requests

Link to chapter — https://serverless-stack.com/examples/how-to-use-middy-to-validate-your-serverless-api-requests.html

This example gives me the following error

Error: Middleware must be an object containing at least one key among “before”, “after”, “onError”

There is almost no info in the web about this error from Middy.

I’m using
Node v18.12.1
@middy/core”: “^4.0.2”,
@middy/http-error-handler”: “^4.0.2”,
@middy/http-json-body-parser”: “^4.0.2”,
@middy/validator”: “^4.0.2”,