app.use(validator()) ^ TypeError: validator is not a function code example

Example 1: validationResult is not defined

const { check, validationResult } = require('express-validator/check');

// or:

const check = require('express-validator/check').check;
const validationResult = require('express-validator/check').validationResult;

Example 2: app.use(validator()) is not a function

console.log(`error: ${err}`);
res.status(code).json({
    error: err
});
// good error handling by express validation Pg 2
// make utils/app.js and write this code inside it