Add correct error messages, allow default state to be none

This commit is contained in:
zandercymatics 2024-04-18 12:14:10 -06:00
parent 7e7919691e
commit 03be457e37
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
4 changed files with 77 additions and 13 deletions

View file

@ -647,7 +647,6 @@ class CisaRepresentativeForm(BaseDeletableRegistrarForm):
cisa_representative_email = forms.EmailField(
required=True,
max_length=None,
error_messages={"invalid": ("Enter your email address in the required format, like name@example.com.")},
label="Your representatives email",
validators=[
MaxLengthValidator(
@ -655,14 +654,17 @@ class CisaRepresentativeForm(BaseDeletableRegistrarForm):
message="Response must be less than 320 characters.",
)
],
error_messages={
"invalid": ("Enter your email address in the required format, like name@example.com."),
"required": ("Enter the email address of your CISA regional representative."),
},
)
class CisaRepresentativeYesNoForm(BaseYesNoForm):
"""Yes/no toggle for the CISA regions question on additional details"""
# Note that these can be set as functions/init if you need more fine-grained control
form_is_checked = property(lambda self: self.domain_request.has_cisa_representative()) # type: ignore
form_is_checked = property(lambda self: self.domain_request.has_cisa_representative)
field_name = "has_cisa_representative"
@ -677,6 +679,12 @@ class AdditionalDetailsForm(BaseDeletableRegistrarForm):
message="Response must be less than 2000 characters.",
)
],
error_messages={
"required": (
"Provide additional details youd like us to know. "
"If you have nothing to add, select “No.”"
)
},
)
@ -684,7 +692,7 @@ class AdditionalDetailsYesNoForm(BaseYesNoForm):
"""Yes/no toggle for the anything else question on additional details"""
# Note that these can be set as functions/init if you need more fine-grained control.
form_is_checked = property(lambda self: self.domain_request.has_anything_else_text()) # type: ignore
form_is_checked = property(lambda self: self.domain_request.has_anything_else_text) # type: ignore
field_name = "has_anything_else_text"