Repository: cal-itp/benefits

Issue:
Remove unused form with-errors logic/code
With Courtesy Cards, we have the browser-based form checks for required fields and `sub` pattern (regex) -- there isn't a way for the user to submit the form with bad inputs, assuming the browser is working as advertised.

Further, when the data gets to our Server, it will be hashed -- there isn't a way for the Server to know if the format of user data was incorrect and/or missing.

All that is to say - we have a ton of HTML/CSS/JS/Python for dealing with form errors that really isn't needed anymore. Let's clean this up.

## Acceptance Criteria

<!-- Remember to consider edge cases -->

- [x] There is not HTML/CSS/JS related to form errors
- [x] The Eligibility form does not deal with form/API errors



Discussion:

Resolving patch:
diff --git a/benefits/core/migrations/0002_sample_data.py b/benefits/core/migrations/0002_sample_data.py
--- a/benefits/core/migrations/0002_sample_data.py
+++ b/benefits/core/migrations/0002_sample_data.py
@@ -138,8 +138,8 @@ def load_sample_data(app, *args, **kwargs):
         form_blurb=_("eligibility.pages.confirm.mst_cc.p[0]"),
         form_sub_label=_("eligibility.forms.confirm.mst_cc.fields.sub"),
         form_sub_help_text=_("eligibility.forms.confirm.mst_cc.fields.sub.help_text"),
-        form_sub_placeholder="TODO: B1234567",
-        form_sub_pattern=".+",
+        form_sub_placeholder="12345",
+        form_sub_pattern=r"\d{5}",
         form_name_label=_("eligibility.forms.confirm.mst_cc.fields.name"),
         form_name_help_text=_("eligibility.forms.confirm.mst_cc.fields.name.help_text"),
         form_name_placeholder="Garcia",
diff --git a/benefits/eligibility/forms.py b/benefits/eligibility/forms.py
--- a/benefits/eligibility/forms.py
+++ b/benefits/eligibility/forms.py
@@ -67,21 +67,6 @@ def __init__(self, verifier: models.EligibilityVerifier, *args, **kwargs):
             label=_(verifier.form_name_label), widget=name_widget, help_text=_(verifier.form_name_help_text)
         )
 
-    def add_api_errors(self, form_errors):
-        """Handle errors passed back from API server related to submitted form values."""
-
-        validation_errors = {
-            field: forms.ValidationError(self._error_messages.get(code, _("core.pages.error.title")), code=code)
-            for (field, code) in form_errors.items()
-            if field in self.fields
-        }
-
-        if len(validation_errors) > 0:
-            logger.warning("Form fields are invalid")
-
-        for (field, err) in validation_errors.items():
-            self.add_error(field, err)
-
     def clean(self):
         if not recaptcha.verify(self.data):
             raise forms.ValidationError("reCAPTCHA failed")
diff --git a/benefits/eligibility/verify.py b/benefits/eligibility/verify.py
--- a/benefits/eligibility/verify.py
+++ b/benefits/eligibility/verify.py
@@ -26,7 +26,6 @@ def eligibility_from_api(verifier, form, agency):
     response = client.verify(sub, name, typenames_to_verify(agency, verifier))
 
     if response.error and any(response.error):
-        form.add_api_errors(response.error)
         return None
     elif any(response.eligibility):
         return list(response.eligibility)


Test patch:
diff --git a/tests/pytest/eligibility/test_verify.py b/tests/pytest/eligibility/test_verify.py
--- a/tests/pytest/eligibility/test_verify.py
+++ b/tests/pytest/eligibility/test_verify.py
@@ -32,7 +32,6 @@ def test_eligibility_from_api_error(mocker, model_TransitAgency, model_Eligibili
     response = eligibility_from_api(model_EligibilityVerifier, form, model_TransitAgency)
 
     assert response is None
-    form.add_api_errors.assert_called_once_with(api_errors)
 
 
 @pytest.mark.django_db
@@ -46,7 +45,6 @@ def test_eligibility_from_api_verified_types(
     response = eligibility_from_api(model_EligibilityVerifier, form, model_TransitAgency)
 
     assert response == verified_types
-    form.add_api_errors.assert_not_called()
 
 
 @pytest.mark.django_db
@@ -60,7 +58,6 @@ def test_eligibility_from_api_no_verified_types(
     response = eligibility_from_api(model_EligibilityVerifier, form, model_TransitAgency)
 
     assert response == verified_types
-    form.add_api_errors.assert_not_called()
 
 
 @pytest.mark.django_db