-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathBOL.coffee
42 lines (34 loc) · 1.04 KB
/
BOL.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
Phone = require('../Phone')
PhoneNumber = require('../PhoneNumber')
# For more info check:
# http://www.howtocallabroad.com/bolivia/
class Bolivia
constructor: ->
@countryName = "Bolivia"
@countryNameAbbr = "BOL"
@countryCode = '591'
@regex = /^(?:(?:(?:\+|)591)|)(?:0|)[23467]\d{7}$/
@optionalTrunkPrefix = '0'
@nationalNumberSeparator = ' '
@nationalDestinationCode = ['2', '3', '4', '6', '7']
specialRules: (withoutCountryCode, withoutNDC, ndc) =>
phone = new PhoneNumber(@countryNameAbbr, @countryCode, ndc, withoutNDC)
if withoutNDC.length is 7
if ndc in ['6', '7']
phone.isMobile = true
phone.nationalDestinationCode = ''
phone.number = withoutCountryCode
else
phone.isMobile = false
return phone
splitNumber: (number) =>
if number.length is 7
return Phone.compact number.split(/(\d{3})(\d{4})/)
else if number.length is 8
return Phone.compact number.split(/(\d{3})(\d{5})/)
return [number]
# register
bolivia = new Bolivia()
Phone.countries['591'] = bolivia
# exports
module.exports = bolivia