diff --git a/src/common/utils/stringHelpers.js b/src/common/utils/stringHelpers.js index a76b885e..c441697d 100644 --- a/src/common/utils/stringHelpers.js +++ b/src/common/utils/stringHelpers.js @@ -353,8 +353,12 @@ export const safeJsonParse = (str) => { // Converts JSON to a string and removes curly brackets, square brackets, and double quotes export const convertJsonToReadableString = (json) => { - const message = JSON.stringify(json) - return message?.replace(/[{}[\]"]+/g, ' ') || '' + try { + const message = JSON.stringify(json) + return message?.replace(/[{}[\]"]+/g, ' ') || '' + } catch (e) { + return 'Error' + } } export const makeTypeSingular = (plural) => { diff --git a/src/common/utils/validationHelpers.js b/src/common/utils/validationHelpers.js index 3c6b1b7c..8c56db2c 100644 --- a/src/common/utils/validationHelpers.js +++ b/src/common/utils/validationHelpers.js @@ -40,7 +40,7 @@ export const definitions = { yup.object({ text: stringWithMax(charCount).min( 1, - 'This field cannot be empty. Remove it if you do not want to inlcude it.', + 'This field cannot be empty. Remove it if you do not want to include it.', ), }), ), diff --git a/src/components/Form/TextArrayField.js b/src/components/Form/TextArrayField.js index 03cb7008..a95cc515 100644 --- a/src/components/Form/TextArrayField.js +++ b/src/components/Form/TextArrayField.js @@ -58,7 +58,9 @@ function TextArrayField({ {errors?.[nameId]?.[index] && (
- {convertJsonToReadableString(errors?.[nameId]?.[index])} + {convertJsonToReadableString( + errors?.[nameId]?.[index]?.text?.message, + )}
)}