-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathESP.coffee
39 lines (31 loc) · 945 Bytes
/
ESP.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
Phone = require('../Phone')
PhoneNumber = require('../PhoneNumber')
# For more info check:
# https://gl.wikipedia.org/wiki/N%C3%BAmeros_de_tel%C3%A9fono_en_Espa%C3%B1a
class Spain
constructor: ->
@countryName = "Spain"
@countryNameAbbr = "ESP"
@countryCode = '34'
@regex = /^(?:(?:\+|)34|)(?:0|)(?:(?:[56789]\d{8}))$/
@optionalTrunkPrefix = '0'
@nationalNumberSeparator = ' '
@nationalDestinationCode =
[
'5', '6', '7', '8', '9'
]
specialRules: (withoutCountryCode, withoutNDC, ndc) =>
phone = new PhoneNumber(@countryNameAbbr, @countryCode, '', withoutNDC)
if withoutNDC.length is 8
phone.number = withoutCountryCode
phone.isMobile = ndc is '6' or ndc is '7'
return phone
splitNumber: (number) =>
if number.length is 9
return Phone.compact number.split(/(\d{3})(\d{3})(\d{3})/)
return [number]
# register
spain = new Spain()
Phone.countries['34'] = spain
# exports
module.exports = spain