Skip to content

Commit

Permalink
updated empty payload to remove strings
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunlumbcgov committed May 14, 2024
1 parent 1481432 commit 132784c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions frontend/src/sharedMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,13 @@ export default {
if (Array.isArray(obj[prop])) {
obj[prop] = obj[prop].filter(item => item !== "");
if (obj[prop].length === 0) {
delete obj[prop];
// Do not delete empty arrays
// delete obj[prop];
obj[prop] = [];
}
} else if (typeof obj[prop] === 'object' && obj[prop] !== null) {
removeEmptyElements(obj[prop]);
if (Object.keys(obj[prop]).length === 0) {
if (Object.keys(obj[prop]).length === 0 && !Array.isArray(obj[prop])) {
delete obj[prop];
}
} else if (obj[prop] === "") {
Expand All @@ -127,7 +129,7 @@ export default {
}
}
return obj;
},
},
isValidDateString(value) {
// Regular expression for YYYY-MM-DD format
const regex = /^\d{4}-\d{2}-\d{2}$/;
Expand Down

0 comments on commit 132784c

Please sign in to comment.