-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathARE.coffee
35 lines (27 loc) · 1011 Bytes
/
ARE.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
Phone = require('../Phone')
PhoneNumber = require('../PhoneNumber')
class UnitedArabEmirates
constructor: ->
@countryName = "United Arab Emirates"
@countryNameAbbr = "ARE"
@countryCode = '971'
@regex = /^(?:\+|)(?:971|)(?:0|)*\d{9,10}$/
@optionalTrunkPrefix = '0'
@nationalNumberSeparator = ' '
@nationalDestinationCode = ['01', '02', '03', '04', '06', '07', '09', '050', '052', '054', '055', '056', '058']
specialRules: (withoutCountryCode, withoutNDC, ndc) =>
phone = new PhoneNumber(@countryNameAbbr, @countryCode, ndc, withoutNDC)
if ndc.length is 3 or ndc[0] is '5'
phone.isMobile = true
return phone
splitNumber: (number) =>
if number.length is 9
return Phone.compact number.split(/(\d{3})(\d{3})(\d{3})/)
else if number.length is 10
return Phone.compact number.split(/(\d{3})(\d{3})(\d{4})/)
return [number]
# register
unitedarabemirates = new UnitedArabEmirates()
Phone.countries['971'] = unitedarabemirates
# exports
module.exports = unitedarabemirates