Skip to content

Commit

Permalink
Added validation for 11 digit toll free numbers (#1121)
Browse files Browse the repository at this point in the history
  • Loading branch information
shivankacker authored Dec 16, 2022
1 parent a08182c commit a4c1781
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
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

0 comments on commit a4c1781

Please sign in to comment.