-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathSAU.coffee
35 lines (27 loc) · 1.01 KB
/
SAU.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 SaudiArabia
constructor: ->
@countryName = "Saudi Arabia"
@countryNameAbbr = "SAU"
@countryCode = '966'
@regex = /^(?:\+|)(?:966|)(?:0|)*\d{9,10}$/
@optionalTrunkPrefix = '0'
@nationalNumberSeparator = ' '
@nationalDestinationCode = ['011', '012', '013', '014', '016', '017', '0811', '050', '053', '055', '051', '058', '059', '054', '056', '0570', '0571', '0572', '0575', '0576', '0577', '0578']
specialRules: (withoutCountryCode, withoutNDC, ndc) =>
phone = new PhoneNumber(@countryNameAbbr, @countryCode, ndc, withoutNDC)
if withoutNDC.length is 6
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
saudiarabia = new SaudiArabia()
Phone.countries['966'] = saudiarabia
# exports
module.exports = saudiarabia