Skip to content

Commit 075f9f7

Browse files
Added functionality to not include blank optional fields in output
Signed-off-by: Natalia Luzuriaga <natalia.luzuriaga@cms.hhs.gov>
1 parent d593afa commit 075f9f7

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

js/formDataToJson.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ function populateObject(data, fields) {
4545
for (const field of fields) {
4646
let value = data[field];
4747

48+
// Does not assign optional properties with blank values
49+
if (value == null || value === "") {
50+
continue;
51+
}
52+
4853
// Adjusts value accordingly if multi-select field
4954
if ((typeof value === "object" && isMultiSelect(value))) {
5055
value = getSelectedOptions(value);

0 commit comments

Comments
 (0)