-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathCOL.coffee
47 lines (39 loc) · 1.25 KB
/
COL.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Phone = require('../Phone')
PhoneNumber = require('../PhoneNumber')
# For more info check:
# https://www.numberingplans.com/?page=dialling&sub=areacodes
# http://en.wikipedia.org/wiki/Telephone_numbers_in_Colombia
# https://www.itu.int/oth/T020200002C/en
class Colombia
constructor: ->
@countryName = "Colombia"
@countryNameAbbr = "COL"
@countryCode = '57'
@regex = /^(?:(?:\+|)57|)(?:(?:[6][0][1245678]\d{7})|(?:3\d{9}))$/
@optionalTrunkPrefix = '0'
@nationalNumberSeparator = ' '
@nationalDestinationCode =
[
'3(\\d{2})', '601', '602', '604', '605', '606', '607', '608'
]
specialRules: (withoutCountryCode, withoutNDC, ndc) =>
phone = new PhoneNumber(@countryNameAbbr, @countryCode, '', withoutNDC)
if withoutCountryCode.indexOf('3') is 0
phone.isMobile = true
phone.number = withoutCountryCode
phone.nationalDestinationCode = ''
return phone
else
phone.nationalDestinationCode = ndc
return phone
splitNumber: (number) =>
if number.length is 7
return Phone.compact number.split(/(\d{3})(\d{4})/)
else if number.length is 10
return Phone.compact number.split(/(\d{3})(\d{3})(\d{4})/)
return [number]
# register
colombia = new Colombia()
Phone.countries['57'] = colombia
# exports
module.exports = colombia