From 8376734ee3a58edc960cb41663de5cc52c760f5b Mon Sep 17 00:00:00 2001 From: Ronan Date: Mon, 16 Oct 2017 11:43:40 +0200 Subject: Handle express-validator error on the client side and fix #96 (#98) * Handle express-validator error on the client side * More meaningfull error for not supported format --- server/middlewares/validators/videos.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'server') diff --git a/server/middlewares/validators/videos.ts b/server/middlewares/validators/videos.ts index deed07524..f63348e66 100644 --- a/server/middlewares/validators/videos.ts +++ b/server/middlewares/validators/videos.ts @@ -23,7 +23,10 @@ import { } from '../../helpers' const videosAddValidator = [ - body('videofile').custom((value, { req }) => isVideoFile(req.files)).withMessage('Should have a valid file'), + body('videofile').custom((value, { req }) => isVideoFile(req.files)).withMessage( + 'This file is not supported. Are you sure it is of the following type : ' + + CONSTRAINTS_FIELDS.VIDEOS.EXTNAME + ), body('name').custom(isVideoNameValid).withMessage('Should have a valid name'), body('category').custom(isVideoCategoryValid).withMessage('Should have a valid category'), body('licence').custom(isVideoLicenceValid).withMessage('Should have a valid licence'), -- cgit v1.2.3