-import * as express from 'express'
+import express from 'express'
import { body, param, query, ValidationChain } from 'express-validator'
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { PluginType } from '../../../shared/models/plugins/plugin.type'
body('npmName')
.optional()
.custom(isNpmPluginNameValid).withMessage('Should have a valid npm name'),
+ body('pluginVersion')
+ .optional()
+ .custom(isPluginVersionValid).withMessage('Should have a valid plugin version'),
body('path')
.optional()
.custom(isSafePath).withMessage('Should have a valid safe path'),
if (!body.path && !body.npmName) {
return res.fail({ message: 'Should have either a npmName or a path' })
}
+ if (body.pluginVersion && !body.npmName) {
+ return res.fail({ message: 'Should have a npmName when specifying a pluginVersion' })
+ }
return next()
}