-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathMEX.coffee
38 lines (31 loc) · 3.33 KB
/
MEX.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
Phone = require('../Phone')
PhoneNumber = require('../PhoneNumber')
# For more info check:
# http://www.sre.gob.mx/austin/Util/LadasMexico.html
# https://www.itu.int/oth/T020200008A/en
class Mexico
constructor: ->
@countryName = "Mexico"
@countryNameAbbr = "MEX"
@countryCode = '52'
@regex = /^(?:(?:\+|)52|)((?:33|55|56|81\d{8})|(?:[2-9][1-9]\d{8}))$/
@optionalTrunkPrefix = ''
@nationalNumberSeparator = ' '
@nationalDestinationCode =
[
"33","55","56","81","221","222","223","224","225","226","227","228","229","231","232","233","235","236","237","238","241","243","244","245","246","247","248","249","271","272","273","274","275","276","278","279","281","282","283","284","285","287","288","294","296","297","311","312","313","314","315","316","317","318","319","321","322","323","324","325","326","327","328","329","341","342","343","344","345","346","347","348","349","351","352","353","354","355","356","357","358","359","371","372","373","374","375","376","377","378","379","381","382","383","384","385","386","387","388","389","391","392","393","394","395","411","412","413","414","415","417","418","419","421","422","423","424","425","426","427","428","429","431","432","433","434","435","436","437","438","440","441","442","443","444","445","446","447","448","449","451","452","453","454","455","456","457","458","459","461","462","463","464","465","466","467","468","469","471","472","473","474","475","476","477","478","479","481","482","483","485","486","487","488","489","492","493","494","495","496","498","499","588","591","592","593","594","595","596","597","599","612","613","614","615","616","618","621","622","623","624","625","626","627","628","629","631","632","633","634","635","636","637","638","639","641","642","643","644","645","646","647","648","649","651","652","653","656","658","659","661","662","663","664","665","666","667","668","669","671","672","673","674","675","676","677","686","687","694","695","696","697","698","711","712","713","714","715","716","717","718","719","721","722","723","724","725","726","727","728","729","731","732","733","734","735","736","737","738","739","741","742","743","744","745","746","747","748","749","751","753","754","755","756","757","758","759","761","762","763","764","765","766","767","768","769","771","772","773","774","775","776","777","778","779","781","782","783","784","785","786","789","791","797","821","823","824","825","826","827","828","829","831","832","833","834","835","836","841","842","844","845","846","861","862","864","866","867","868","869","871","872","873","877","878","891","892","894","897","899","913","914","916","917","918","919","921","922","923","924","932","933","934","936","937","938","951","953","954","958","961","962","963","964","965","966","967","968","969","971","972","981","982","983","984","985","986","987","988","991","992","993","994","995","996","997","998","999"
]
specialRules: (withoutCountryCode, withoutNDC, ndc) =>
if withoutNDC.length is 7 or withoutNDC.length is 8
return new PhoneNumber(@countryNameAbbr, @countryCode, ndc, withoutNDC)
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{4})(\d{4})/)
return [number]
# register
mexico = new Mexico()
Phone.countries['52'] = mexico
# exports
module.exports = mexico