From d57beb9f47c11daed82428449260f184eb8d5714 Mon Sep 17 00:00:00 2001 From: jos Date: Wed, 15 Aug 2018 10:55:34 +0200 Subject: [PATCH] Minor refactoring --- src/js/textmode.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/js/textmode.js b/src/js/textmode.js index 1568558..6c5027e 100644 --- a/src/js/textmode.js +++ b/src/js/textmode.js @@ -779,14 +779,14 @@ textmode.validate = function () { var errorLocations = util.getPositionForPath(jsonText, errorPaths); me.annotations = errorLocations.map(function (errLoc) { var validationErrors = errors.filter(function(err){ return err.dataPath === errLoc.path; }); - var validationError = validationErrors.reduce(function(acc, curr) { acc.message += '\n' + curr.message; return acc; }); - if (validationError) { + var message = validationErrors.map(function(err) { return err.message }).join('\n'); + if (message) { return { row: errLoc.line, column: errLoc.column, - text: "Schema Validation Error: \n" + validationError.message, - type: "warning", - source: "jsoneditor", + text: 'Schema validation error' + (validationErrors.length !== 1 ? 's' : '') + ': \n' + message, + type: 'warning', + source: 'jsoneditor', } }