Skip to content

Commit

Permalink
fix: handle invalid date in date fields
Browse files Browse the repository at this point in the history
  • Loading branch information
9sneha-n committed Nov 23, 2024
1 parent 167a02c commit 71b3e6b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/domain/entities/Questionnaire/QuestionnaireRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,17 @@ export const getQuestionValueByType = (question: Question): string => {
case "boolean":
return question.value === undefined ? "false" : question.value.toString();
case "date":
return question.value?.toISOString().split("T")[0] ?? "";
try {
return question.value?.toISOString().split("T")[0] ?? "";
} catch (e) {
return ""; //Handle invalid date
}
case "datetime":
return question.value?.toString() ?? "";

try {
return question.value?.toString() ?? "";
} catch (e) {
return ""; //Handle invalid date
}
case "number":
case "text":
return question.value ?? "";
Expand Down

0 comments on commit 71b3e6b

Please sign in to comment.