Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added validation for 11 digit toll free numbers #1121

Merged
merged 2 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions care/facility/models/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from care.facility.models.facility import Facility
from care.facility.models.json_schema.asset import ASSET_META
from care.facility.models.mixins.permissions.asset import AssetsPermissionMixin
from care.users.models import User, phone_number_regex
from care.users.models import User, phone_number_regex_11
from care.utils.assetintegration.asset_classes import AssetClasses
from care.utils.models.base import BaseModel
from care.utils.models.validators import JSONFieldSchemaValidator
Expand Down Expand Up @@ -78,7 +78,7 @@ class Status(enum.Enum):
vendor_name = models.CharField(max_length=1024, blank=True, null=True)
support_name = models.CharField(max_length=1024, blank=True, null=True)
support_phone = models.CharField(
max_length=14, validators=[phone_number_regex], default=""
max_length=14, validators=[phone_number_regex_11], default=""
)
support_email = models.EmailField(blank=True, null=True)
qr_code_id = models.CharField(max_length=1024, blank=True, default=None, null=True)
Expand Down
7 changes: 7 additions & 0 deletions care/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ def reverse_choices(choices):
code="invalid_mobile",
)

phone_number_regex_11 = RegexValidator(
# allow 10 to 11 digit mobile numbers if the first 4 digits are 1800
regex=r"^((\+91|91|0)[\- ]{0,1})?[456789]\d{9}|1800\d{6,7}$",
message="Please Enter 10/11 digit mobile/landline/tollfree number",
code="invalid_mobile",
)

DISTRICT_CHOICES = [
(1, "Thiruvananthapuram"),
(2, "Kollam"),
Expand Down