From 7a37c58b2bc2b84195bf13d924e7412b40849749 Mon Sep 17 00:00:00 2001 From: ytqh Date: Sun, 9 Mar 2025 20:52:29 +0800 Subject: [PATCH] bugfix: fix major check logic --- api/controllers/service_api_with_auth/user/profile.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/controllers/service_api_with_auth/user/profile.py b/api/controllers/service_api_with_auth/user/profile.py index 16d162177c..a7ae6ba930 100644 --- a/api/controllers/service_api_with_auth/user/profile.py +++ b/api/controllers/service_api_with_auth/user/profile.py @@ -69,7 +69,7 @@ class UserProfile(Resource): enum: [male, female, unknown] major: type: string - maxLength: 20 + maxLength: 50 responses: 200: description: Profile updated successfully @@ -106,10 +106,10 @@ class UserProfile(Resource): if 'major' in data: major = data['major'] - if isinstance(major, str) and len(major) > 20: - return {"success": False, "message": "Major exceeds maximum length"}, 400 - elif major is not None: # Handle non-string or None values appropriately + if not isinstance(major, str): return {"success": False, "message": "Major must be a string value"}, 400 + if len(major) > 50: + return {"success": False, "message": "Major exceeds maximum length of 50"}, 400 validated_data['major'] = major