From 63b856b7268ba615e75d9c7d1c09260661847be6 Mon Sep 17 00:00:00 2001 From: andrey-canon Date: Tue, 16 Jul 2024 16:22:20 -0500 Subject: [PATCH] feat: update phone number validator message --- .../0045_alter_userprofile_phone_number.py | 19 +++++++++++++++++++ common/djangoapps/student/models/user.py | 5 ++++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 common/djangoapps/student/migrations/0045_alter_userprofile_phone_number.py diff --git a/common/djangoapps/student/migrations/0045_alter_userprofile_phone_number.py b/common/djangoapps/student/migrations/0045_alter_userprofile_phone_number.py new file mode 100644 index 000000000000..a37bca01d7ce --- /dev/null +++ b/common/djangoapps/student/migrations/0045_alter_userprofile_phone_number.py @@ -0,0 +1,19 @@ +# Generated by Django 3.2.21 on 2024-07-16 21:18 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('student', '0044_courseenrollmentcelebration_celebrate_weekly_goal'), + ] + + operations = [ + migrations.AlterField( + model_name='userprofile', + name='phone_number', + field=models.CharField(blank=True, max_length=50, null=True, validators=[django.core.validators.RegexValidator(message="Phone number must start with '+' (optional) followed by digits (0-9) only.", regex='^\\+?1?\\d*$')]), + ), + ] diff --git a/common/djangoapps/student/models/user.py b/common/djangoapps/student/models/user.py index f29480e0ce02..40ebd33c719d 100644 --- a/common/djangoapps/student/models/user.py +++ b/common/djangoapps/student/models/user.py @@ -548,7 +548,10 @@ class Meta: goals = models.TextField(blank=True, null=True) bio = models.CharField(blank=True, null=True, max_length=3000, db_index=False) profile_image_uploaded_at = models.DateTimeField(null=True, blank=True) - phone_regex = RegexValidator(regex=r'^\+?1?\d*$', message="Phone number can only contain numbers.") + phone_regex = RegexValidator( + regex=r'^\+?1?\d*$', + message="Phone number must start with '+' (optional) followed by digits (0-9) only.", + ) phone_number = models.CharField(validators=[phone_regex], blank=True, null=True, max_length=50) @property