-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathROU.coffee
43 lines (32 loc) · 1.02 KB
/
ROU.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
Phone = require('../Phone')
PhoneNumber = require('../PhoneNumber')
class Romania
constructor: ->
@countryName = "Romania"
@countryNameAbbr = "ROU"
@countryCode = '40'
@regex = /^(?:(?:\+|)40|)(?:0|)(?:(?:[2-7]\d{8}))$/
@optionalTrunkPrefix = '0'
@nationalNumberSeparator = ' '
@nationalDestinationCode = []
specialRules: (withoutCountryCode, withoutNDC, ndc) =>
if withoutCountryCode[0] is '0'
# Sometimes clients may type their phones with a leading zero
# we should strip that
withoutNDC = withoutCountryCode.slice(1)
if withoutCountryCode.slice(0,2) is '40'
withoutNDC = withoutCountryCode.slice(2)
phone = new PhoneNumber(@countryNameAbbr, @countryCode, ndc, withoutNDC)
if withoutCountryCode[0] in ['6','7']
phone.isMobile = true
return phone
else
phone.isMobile = false
return phone
splitNumber: (number) =>
return Phone.compact number.split(/(\d{3})(\d{3})(\d{3})/)
# register
romania = new Romania()
Phone.countries['40'] = romania
# exports
module.exports = romania