From 18f5c68e3ecb5cb14cbd3c96e45aed535c6565a9 Mon Sep 17 00:00:00 2001
From: jasquat <jasquat@users.noreply.github.com>
Date: Mon, 15 May 2023 11:54:36 -0400
Subject: [PATCH] do not blow up if the date is a bad format in a react json
 schema form w/ burnettk

---
 .../themes/carbon/BaseInputTemplate/BaseInputTemplate.tsx  | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/spiffworkflow-frontend/src/themes/carbon/BaseInputTemplate/BaseInputTemplate.tsx b/spiffworkflow-frontend/src/themes/carbon/BaseInputTemplate/BaseInputTemplate.tsx
index cf153157..6e8af43a 100644
--- a/spiffworkflow-frontend/src/themes/carbon/BaseInputTemplate/BaseInputTemplate.tsx
+++ b/spiffworkflow-frontend/src/themes/carbon/BaseInputTemplate/BaseInputTemplate.tsx
@@ -100,12 +100,15 @@ export default function BaseInputTemplate<
   if (type === 'date') {
     // display the date in a date input box as the config wants.
     // it should in be y-m-d when it gets here.
-    let dateValue: string | null = '';
+    let dateValue: string | null = value;
     if (value || value === 0) {
       if (value.length < 10) {
         dateValue = value;
       } else {
-        dateValue = ymdDateStringToConfiguredFormat(value);
+        try {
+          dateValue = ymdDateStringToConfiguredFormat(value);
+          // let the date component and form validators handle bad dates and do not blow up
+        } catch (RangeError) {}
       }
     }