From b71c496d978b15361a53246aa7c2319ab5a388a6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 3 Feb 2020 11:32:34 +0200 Subject: [PATCH] chore(deps): update dependency @types/hapi__joi to v16.0.9 (#3185) --- packages/netlify-cms-proxy-server/package.json | 2 +- .../netlify-cms-proxy-server/src/middlewares/joi/index.ts | 8 +++----- yarn.lock | 8 ++++---- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/netlify-cms-proxy-server/package.json b/packages/netlify-cms-proxy-server/package.json index aa3862e0..58578c31 100644 --- a/packages/netlify-cms-proxy-server/package.json +++ b/packages/netlify-cms-proxy-server/package.json @@ -32,7 +32,7 @@ "devDependencies": { "@types/cors": "^2.8.6", "@types/express": "^4.17.2", - "@types/hapi__joi": "16.0.6", + "@types/hapi__joi": "16.0.9", "@types/jest": "^24.9.0", "@types/morgan": "^1.7.37", "@types/node": "^13.1.7", diff --git a/packages/netlify-cms-proxy-server/src/middlewares/joi/index.ts b/packages/netlify-cms-proxy-server/src/middlewares/joi/index.ts index df135a99..b2cdd4b0 100644 --- a/packages/netlify-cms-proxy-server/src/middlewares/joi/index.ts +++ b/packages/netlify-cms-proxy-server/src/middlewares/joi/index.ts @@ -190,13 +190,11 @@ export const joi = (schema: Joi.Schema) => ( next: express.NextFunction, ) => { const { error } = schema.validate(req.body, { allowUnknown: true }); - const valid = error == null; - - if (valid) { - next(); - } else { + if (error) { const { details } = error; const message = details.map(i => i.message).join(','); res.status(422).json({ error: message }); + } else { + next(); } }; diff --git a/yarn.lock b/yarn.lock index df62e01c..6e93fd53 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2978,10 +2978,10 @@ "@types/minimatch" "*" "@types/node" "*" -"@types/hapi__joi@16.0.6": - version "16.0.6" - resolved "https://registry.yarnpkg.com/@types/hapi__joi/-/hapi__joi-16.0.6.tgz#aa8f7dff93fdd3db6506ca2433a8302d8819fad1" - integrity sha512-rpU8FNMGxhYIF6bUlxZYO4drNjqUWCGrf4UINABAJzdcrPs4bP+Bz5VXzp8rOPZsNynnaDXbiU/MyjOGlfeczg== +"@types/hapi__joi@16.0.9": + version "16.0.9" + resolved "https://registry.yarnpkg.com/@types/hapi__joi/-/hapi__joi-16.0.9.tgz#0ad11f9de3753748444ac16249a264fc7c798ab4" + integrity sha512-FV+rJxm4UBxBsRvT5hpiRvnxbpi9iJu4qdwXQvNXf6eXJkcgKGlTwHnstIDAxSTKTUMSmpJnyXpr6XI9X/4SjA== "@types/history@*": version "4.7.5"