Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Chamuth Chamandana Thilakarathne Chamuth

🏠
Working from home
View GitHub Profile
@Chamuth
Chamuth / lkphones.ts
Created Nov 21, 2018
Validate Sri Lankan phones numbers and get their carrier
View lkphones.ts
export module LKPhoneValidator
{
export function Validate(phone : string) : PhoneValidation
{
// remove starting +94
phone = phone.replace("+94", "0");
// Consider number length
if ((phone.startsWith('0') && phone.length == 10) || (!phone.startsWith('0') && phone.length == 9) && /^\d+$/.test(phone))
{
You can’t perform that action at this time.