koa-context-validator icon indicating copy to clipboard operation
koa-context-validator copied to clipboard

I'm getting this error: TypeError: validator is not a function

Open juanpablopiano opened this issue 2 years ago • 1 comments

I'm using this library to validate the body of the request using koa-router library. This is the code of one of the routes

import Router from 'koa-router';
import { getOneMovieController, getAllMoviesController, updatePlotController } from '../Controllers/movie.js';
import validator from 'koa-context-validator';
import { updatePlotSchema } from '../Validations/movie.js';

const router = new Router({
	prefix: '/api/v1/movie',
});

// Get one movie Route
router.get('/get-one/:title', getOneMovieController);

// Get all movies Route
router.get('/get-all', getAllMoviesController);

// Update a movie plot Route
router.post('/update-plot', validator(updatePlotSchema), updatePlotController);

export default router;

The part where I'm trying to use the validator function with the updatePlotSchema is giving me this error as in the validate funcion does not exist

juanpablopiano avatar Jan 27 '22 00:01 juanpablopiano