mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-04 10:13:30 +02:00
Fix blanks
This commit is contained in:
parent
ab6cbb93c6
commit
6b6aed8f24
2 changed files with 5 additions and 8 deletions
|
@ -384,7 +384,7 @@ class AlternativeDomainForm(RegistrarForm):
|
|||
"""Validation code for domain names."""
|
||||
requested = self.cleaned_data.get("alternative_domain", None)
|
||||
validated = DraftDomain.validate_and_handle_errors(
|
||||
requested, ValidationErrorReturnType.FORM_VALIDATION_ERROR, prevent_blank=False
|
||||
requested, ValidationErrorReturnType.FORM_VALIDATION_ERROR, blank_ok=True
|
||||
)
|
||||
return validated
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ class DomainHelper:
|
|||
return domain
|
||||
|
||||
@classmethod
|
||||
def validate_and_handle_errors(cls, domain, error_return_type, prevent_blank=True, display_success=False):
|
||||
def validate_and_handle_errors(cls, domain, error_return_type, blank_ok=False, display_success=False):
|
||||
"""
|
||||
Validates the provided domain and handles any validation errors.
|
||||
|
||||
|
@ -71,7 +71,7 @@ class DomainHelper:
|
|||
Args:
|
||||
domain (str): The domain to validate.
|
||||
error_return_type (ValidationErrorReturnType): The type of error response to return if validation fails.
|
||||
prevent_blank (bool, optional): Whether to return an exception if the input is blank. Defaults to True.
|
||||
blank_ok (bool, optional): Whether to return an exception if the input is blank. Defaults to False.
|
||||
display_success (bool, optional): Whether to return a success response if validation is successful. Defaults to False.
|
||||
|
||||
Returns:
|
||||
|
@ -81,12 +81,9 @@ class DomainHelper:
|
|||
""" # noqa
|
||||
|
||||
try:
|
||||
validated = cls.validate(domain)
|
||||
validated = cls.validate(domain, blank_ok)
|
||||
except errors.BlankValueError:
|
||||
if not prevent_blank:
|
||||
return DomainHelper._return_form_error_or_json_response(error_return_type, code="required")
|
||||
else:
|
||||
return validated
|
||||
return DomainHelper._return_form_error_or_json_response(error_return_type, code="required")
|
||||
except errors.ExtraDotsError:
|
||||
return DomainHelper._return_form_error_or_json_response(error_return_type, code="extra_dots")
|
||||
except errors.DomainUnavailableError:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue