diff --git a/public/scripts/BulkEditOverlay.js b/public/scripts/BulkEditOverlay.js index 38b21615b..c7e6721f4 100644 --- a/public/scripts/BulkEditOverlay.js +++ b/public/scripts/BulkEditOverlay.js @@ -81,7 +81,7 @@ class CharacterContextMenu { body: JSON.stringify(data), }).then((response) => { if (response.ok) toggleFavoriteHighlight(characterId) - else toastr.error('Character not saved. Error: ' + response.json()?.message) + else response.json().then(json => toastr.error('Character not saved. Error: ' + json.message + '. Field: ' + json.error)); }); } diff --git a/server.js b/server.js index ee0658b6f..afd7a9478 100644 --- a/server.js +++ b/server.js @@ -1189,7 +1189,8 @@ app.post("/v2/editcharacterattribute", jsonParser, async function (request, resp const validator = new TavernCardValidator(character); - if (true === validator.validateV2()) { + //Accept either V1 or V2. + if (validator.validate()) { await charaWrite( avatarPath, JSON.stringify(character), @@ -1198,7 +1199,8 @@ app.post("/v2/editcharacterattribute", jsonParser, async function (request, resp 'Character saved' ); } else { - response.status(400).send({message: `Validation failed for card ${character.name}`, field: validator.lastValidationError}); + console.log(validator.lastValidationError) + response.status(400).send({message: `Validation failed for ${character.name}`, error: validator.lastValidationError}); } } catch (exception) { response.status(500).send({message: 'Unexpected error while saving character.', error: exception.toString()}); diff --git a/src/validator/TavernCardValidator.js b/src/validator/TavernCardValidator.js index 7dbdc3034..dabd0b595 100644 --- a/src/validator/TavernCardValidator.js +++ b/src/validator/TavernCardValidator.js @@ -88,7 +88,7 @@ class TavernCardValidator { const data = this.card.data; if (!data) { - this.#lastValidationError = 'data'; + this.#lastValidationError = 'No tavern card data found'; return false; }