mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
zever/lib/validator: Rename function to validate_choice_field_data.
This commit is contained in:
committed by
Tim Abbott
parent
799a5e73c0
commit
f25e00bcaa
@@ -228,7 +228,7 @@ def check_url(var_name: str, val: object) -> Optional[str]:
|
|||||||
except ValidationError:
|
except ValidationError:
|
||||||
return _('%s is not a URL') % (var_name,)
|
return _('%s is not a URL') % (var_name,)
|
||||||
|
|
||||||
def validate_field_data(field_data: ProfileFieldData) -> Optional[str]:
|
def validate_choice_field_data(field_data: ProfileFieldData) -> Optional[str]:
|
||||||
"""
|
"""
|
||||||
This function is used to validate the data sent to the server while
|
This function is used to validate the data sent to the server while
|
||||||
creating/editing choices of the choice field in Organization settings.
|
creating/editing choices of the choice field in Organization settings.
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ from zerver.lib.actions import (try_add_realm_custom_profile_field,
|
|||||||
from zerver.lib.response import json_success, json_error
|
from zerver.lib.response import json_success, json_error
|
||||||
from zerver.lib.types import ProfileFieldData
|
from zerver.lib.types import ProfileFieldData
|
||||||
from zerver.lib.validator import (check_dict, check_list, check_int,
|
from zerver.lib.validator import (check_dict, check_list, check_int,
|
||||||
validate_field_data, check_capped_string)
|
validate_choice_field_data, check_capped_string)
|
||||||
|
|
||||||
from zerver.models import (UserProfile,
|
from zerver.models import (UserProfile,
|
||||||
CustomProfileField, custom_profile_fields_for_realm)
|
CustomProfileField, custom_profile_fields_for_realm)
|
||||||
@@ -60,7 +60,7 @@ def create_realm_custom_profile_field(request: HttpRequest,
|
|||||||
if field_type == CustomProfileField.CHOICE and len(field_data) < 1:
|
if field_type == CustomProfileField.CHOICE and len(field_data) < 1:
|
||||||
return json_error(_("Field must have at least one choice."))
|
return json_error(_("Field must have at least one choice."))
|
||||||
|
|
||||||
error = validate_field_data(field_data)
|
error = validate_choice_field_data(field_data)
|
||||||
if error:
|
if error:
|
||||||
return json_error(error)
|
return json_error(error)
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ def update_realm_custom_profile_field(request: HttpRequest, user_profile: UserPr
|
|||||||
converter=ujson.loads),
|
converter=ujson.loads),
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
validate_field_name_and_hint(name, hint)
|
validate_field_name_and_hint(name, hint)
|
||||||
error = validate_field_data(field_data)
|
error = validate_choice_field_data(field_data)
|
||||||
if error:
|
if error:
|
||||||
return json_error(error)
|
return json_error(error)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user