Is it common to have the phone number

(SOLVED) Is it common to have the phone number provided as invalid? Is there any rule to pass a "valid" phone number?
No description
14 Replies
Prastoin
Prastoin2mo ago
Hey @Pedro Talaia could you please share the request format ? this should be following
@ValidateIf((_object, value) => value !== null)
@IsQuotedString()
primaryPhoneNumber: string | null;

@ValidateIf((_object, value) => value !== null)
@IsQuotedString()
primaryPhoneCountryCode: string | null;

@ValidateIf((_object, value) => value !== null)
@IsQuotedString()
primaryPhoneCallingCode: string | null;

@ValidateIf((_object, value) => value !== null)
@IsObject()
additionalPhones: object | null;
@ValidateIf((_object, value) => value !== null)
@IsQuotedString()
primaryPhoneNumber: string | null;

@ValidateIf((_object, value) => value !== null)
@IsQuotedString()
primaryPhoneCountryCode: string | null;

@ValidateIf((_object, value) => value !== null)
@IsQuotedString()
primaryPhoneCallingCode: string | null;

@ValidateIf((_object, value) => value !== null)
@IsObject()
additionalPhones: object | null;
Pedro Talaia
Pedro TalaiaOP2mo ago
Sorry but where can I check this? I can't check this on the workflow run right? It's on the Docker Container run ?
Pedro Talaia
Pedro TalaiaOP2mo ago
{ "page": "https://apbizz.com/contact/", "email": "example@gmail.com", "phone": "88191388412", "source": "https://apbizz.com", "company": "google", "message": "", "service": [ "ABIZZ" ], "full_name": "John Doe", "timestamp": 1760095308 },
C. Dias
A+Bizz
Contact - A+Bizz
Contact us for a free diagnostic of your business Schedule a complimentary video call with our team. We'll conduct a pre-diagnostic of your company and provide a tailored budget proposal based on your specific needs. Frequently Asked Questions About Our Company Product & Technology Pricing & Purchasing
Pedro Talaia
Pedro TalaiaOP2mo ago
I have a function to run to "check" the phone number: export const main = async (params: { phone: string; full_name: string; timestamp: number; }): Promise<object> => { const { full_name, phone, timestamp } = params; // ---- Name split ---- const parts = (full_name "").trim().split(/\s+/); const firstName = parts[0] ""; const lastName = parts.length > 1 ? parts.slice(1).join(" ") : ""; // ---- Phone normalize + country code ---- // remove spaces; convert leading '00' to '+'; keep only + and digits const normalized = (phone "") .trim() .replace(/\s+/g, "") .replace(/^00/, "+") .replace(/(?!^+)\D/g, ""); // strip non-digits except leading '+' const ccMatch = normalized.match(/^+?(\d{1,4})/); const countryCode = ccMatch ? ccMatch[1] : ""; // ---- Format timestamp -> "MM/DD/YYYY HH:mm" (local time) ---- const dateObj = new Date((timestamp 0) * 1000); if (isNaN(dateObj.getTime())) { return { error: "Invalid timestamp" }; } const mm = String(dateObj.getMonth() + 1).padStart(2, "0"); const dd = String(dateObj.getDate()).padStart(2, "0"); const yyyy = dateObj.getFullYear(); const hh = String(dateObj.getHours()).padStart(2, "0"); const min = String(dateObj.getMinutes()).padStart(2, "0"); const date = ${mm}/${dd}/${yyyy} ${hh}:${min}; return { firstName, lastName, phone: normalized, countryCode, date }; }; And to return as a string as well @Prastoin any ideas about this ?
Pedro Talaia
Pedro TalaiaOP2mo ago
Again the same
No description
Pedro Talaia
Pedro TalaiaOP2mo ago
@thomast would you be able to help me with this one ?
Pedro Talaia
Pedro TalaiaOP2mo ago
The phone is a "string" as requested right on the request format that prastoin shared
No description
thomast
thomast2mo ago
did you set the country code? May I see the Node tab of your step so I can try to reproduce?
Pedro Talaia
Pedro TalaiaOP2mo ago
No, I didn't setup the country code Yes OMW
Pedro Talaia
Pedro TalaiaOP2mo ago
export const main = async (params: { phone: string; full_name: string; timestamp: number; }): Promise<object> => { const { full_name, phone, timestamp } = params; // ---- Name split ---- const parts = (full_name "").trim().split(/\s+/); const firstName = parts[0] ""; const lastName = parts.length > 1 ? parts.slice(1).join(" ") : ""; // ---- Phone normalize + country code ---- // remove spaces; convert leading '00' to '+'; keep only + and digits const normalized = (phone "") .trim() .replace(/\s+/g, "") .replace(/^00/, "+") .replace(/(?!^+)\D/g, ""); // strip non-digits except leading '+' const ccMatch = normalized.match(/^+?(\d{1,4})/); const countryCode = ccMatch ? ccMatch[1] : ""; // ---- Format timestamp -> "MM/DD/YYYY HH:mm" (local time) ---- const dateObj = new Date((timestamp 0) * 1000); if (isNaN(dateObj.getTime())) { return { error: "Invalid timestamp" }; } const mm = String(dateObj.getMonth() + 1).padStart(2, "0"); const dd = String(dateObj.getDate()).padStart(2, "0"); const yyyy = dateObj.getFullYear(); const hh = String(dateObj.getHours()).padStart(2, "0"); const min = String(dateObj.getMinutes()).padStart(2, "0"); const date = ${mm}/${dd}/${yyyy} ${hh}:${min}; return { firstName, lastName, phone: normalized, countryCode, date }; };
No description
No description
Pedro Talaia
Pedro TalaiaOP2mo ago
I added "no country"
No description
Pedro Talaia
Pedro TalaiaOP2mo ago
Perhaps it's because of that?
thomast
thomast2mo ago
yep this is the missing country code the issue
Pedro Talaia
Pedro TalaiaOP2mo ago
Thanks @thomast I will pass a default value and then adapt when we can add dynamically

Did you find this page helpful?