zever/lib/validator: Rename function to validate_choice_field_data.

This commit is contained in:
Yashashvi Dave
2019-06-04 13:28:13 +05:30
committed by Tim Abbott
parent 799a5e73c0
commit f25e00bcaa
2 changed files with 4 additions and 4 deletions

View File

@@ -228,7 +228,7 @@ def check_url(var_name: str, val: object) -> Optional[str]:
except ValidationError:
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
creating/editing choices of the choice field in Organization settings.

View File

@@ -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.types import ProfileFieldData
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,
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:
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:
return json_error(error)
@@ -98,7 +98,7 @@ def update_realm_custom_profile_field(request: HttpRequest, user_profile: UserPr
converter=ujson.loads),
) -> HttpResponse:
validate_field_name_and_hint(name, hint)
error = validate_field_data(field_data)
error = validate_choice_field_data(field_data)
if error:
return json_error(error)