From 48175e14fe0aa1d298d7f77407c1624d89a2374e Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 1 Apr 2019 22:34:20 +0000 Subject: [PATCH] --- ayanova/devdocs/todo.txt | 4 ---- ayanova/src/api/gzvalidate.js | 31 ++++++++++++++++++++----------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index 71fec149..5cb48623 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -14,10 +14,6 @@ TODO CLIENT STUFF TODO NEXT -Happy Monday muthafucka! ;) - -*** Add *all* api error codes to localized text over in the server project -*** Continue on with below, was at gzvalidate see area that says *****THIS! Get broken server rule to display in vue properly diff --git a/ayanova/src/api/gzvalidate.js b/ayanova/src/api/gzvalidate.js index 80d1b981..fc6d5851 100644 --- a/ayanova/src/api/gzvalidate.js +++ b/ayanova/src/api/gzvalidate.js @@ -319,8 +319,7 @@ Here are all the API level error codes that can be returned by the API server: */ var ret = []; - -return ret; + //return ret; //check for errors if we have any errors if (!v.$_.isEmpty(v.serverError)) { @@ -344,18 +343,28 @@ return ret; //Specific field validation errors are in an array in "details" key if (!v.$_.isEmpty(v.serverError.details)) { //See if this key is in the details array - var errorsForField= v.$_.where(v.serverError.details, {target: ref}); - if(errorsForField.length>0){ - *****THIS! + var errorsForField = v.$_.filter(v.serverError.details, { + target: ref + }); + if (errorsForField.length > 0) { + var allFldErrors = ""; //iterate the errorsForField objects, build a return message for each error separated by a newline and Bob's your lobster - v.$_.each(errorsForField,function(ve){ - var err=""; - if(ve.message){ - err=err+ve.message; + v.$_.each(errorsForField, function(ve) { + var fldErr = ""; + var fldErrorCode = parseInt(ve.error); + fldErr = + v.$gzlocale.get("ErrorAPI" + fldErrorCode.toString()) + + " [" + + ve.error + + "]"; + if (ve.message) { + fldErr += ve.message; } - }) - } + allFldErrors += fldErr + "\n"; + }); + return allFldErrors.trimRight("\n"); + } } else { if (v.$gzdevmode()) { throw "DEV ERROR gzvalidate::ServerErrors -> on field validation error no 'details' key was found to show which field had the error";