(20250807) - Fixed Number validation issue for whatsapp nimbus whatsapp send - for value recipientNo.
This commit is contained in:
@@ -136,6 +136,12 @@ class NimbusWhatsAppMessage(BaseModel):
|
||||
default=None
|
||||
)
|
||||
|
||||
countryCode: str | None = Field(
|
||||
description="Country Code.",
|
||||
frozen=True,
|
||||
default="91"
|
||||
)
|
||||
|
||||
# ┏┓ ┏•
|
||||
# ┃ ┏┓┏┓╋┓┏┓
|
||||
# ┗┛┗┛┛┗┛┗┗┫
|
||||
@@ -170,10 +176,21 @@ class NimbusWhatsAppMessage(BaseModel):
|
||||
@field_validator("recipientNo", mode = "before")
|
||||
def validate_contact_nos(cls, value):
|
||||
value = regex.replace(text = str(value), pattern = r"[^\d]", substitute_text = "")
|
||||
if len(value) > 10: value = regex.replace(text = str(value), pattern = r"^(91)", substitute_text = "")
|
||||
value = regex.find_first(text = str(value), pattern = r"^[\d]{10}")
|
||||
# if len(value) > 10: value = regex.replace(text = str(value), pattern = r"^(91)", substitute_text = "")
|
||||
# value = regex.find_first(text = str(value), pattern = r"^[\d]{10}")
|
||||
return value
|
||||
|
||||
# @field_validator("countryCode", mode="before")
|
||||
# def validate_country_code(cls, value):
|
||||
# print("value", value)
|
||||
# if not isinstance(value, str):
|
||||
# raise ValueError("Country code must be a string.")
|
||||
#
|
||||
# if any(c.numeric == value for c in countries):
|
||||
# return value
|
||||
#
|
||||
# raise ValueError(f"Invalid country code: {value}")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user