Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clabe-validator

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clabe-validator - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

24

clabe.js

@@ -1,2 +0,2 @@

// CLABE Validator v1.0.3
// CLABE Validator v1.0.4
// github.com/center-key/clabe-validator

@@ -7,2 +7,4 @@ // MIT License

version: '1.0.4',
calcChecksum: function(clabeNum) {

@@ -23,16 +25,16 @@ // Returns the checksum calculated from the first 17 characters of CLABE number.

if (typeof clabeNum !== 'string')
throw 'clabe.validator.check(clabeNum) -- Parameter must be a string';
throw 'clabe.validator.check(clabeNum) -- Expected string, got: ' + typeof clabeNum;
var bankCode = clabeNum.substr(0, 3);
var cityCode = clabeNum.substr(3, 3);
var checksum = parseInt(clabeNum.substr(17, 1));
function makeCityMap() {
clabe.city = {};
function prefix(code) { return clabe.city[code] ? clabe.city[code] + ', ' : ''; }
function addCity(city) { clabe.city[city[0]] = prefix(city[0]) + city[1]; } //0: code, 1: name
function makeCitiesMap() {
clabe.citiesMap = {};
function prefix(code) { return clabe.citiesMap[code] ? clabe.citiesMap[code] + ', ' : ''; }
function addCity(city) { clabe.citiesMap[city[0]] = prefix(city[0]) + city[1]; } //0: code, 1: name
clabe.cities.forEach(addCity);
}
if (!clabe.city)
makeCityMap();
var bank = clabe.bank[parseInt(bankCode)];
var city = clabe.city[parseInt(cityCode)];
if (!clabe.citiesMap)
makeCitiesMap();
var bank = clabe.banksMap[parseInt(bankCode)];
var city = clabe.citiesMap[parseInt(cityCode)];
function calcChecksum() { return clabe.calcChecksum(clabeNum); }

@@ -68,3 +70,3 @@ function getErrorMessage() {

bank: { //source: https://es.wikipedia.org/wiki/CLABE#C.C3.B3digo_de_banco (Jan 9, 2017)
banksMap: { //source: https://es.wikipedia.org/wiki/CLABE#C.C3.B3digo_de_banco (Jan 9, 2017)
2: 'Banco Nacional de México',

@@ -71,0 +73,0 @@ 6: 'Banco Nacional de Comercio Exterior',

@@ -1,2 +0,2 @@

//CLABE Validator v1.0.3 ~ github.com/center-key/clabe-validator ~ MIT
var clabe={calcChecksum:function(a){var o=0;return a.split("").slice(0,17).forEach(function(a,e){o+=parseInt(a)*[3,7,1][e%3]%10}),(10-o%10)%10},validate:function(a){if("string"!=typeof a)throw"clabe.validator.check(clabeNum) -- Parameter must be a string";var e=a.substr(0,3),o=a.substr(3,3),n=parseInt(a.substr(17,1));clabe.city||(clabe.city={},clabe.cities.forEach(function(a){var e;clabe.city[a[0]]=(e=a[0],(clabe.city[e]?clabe.city[e]+", ":"")+a[1])}));var l=clabe.bank[parseInt(e)],i=clabe.city[parseInt(o)];function c(){return clabe.calcChecksum(a)}var r=18!==a.length?"Must be exactly 18 digits long":/[0-9]{18}/.test(a)?c()!==n?"Invalid checksum, last digit should be: "+c():l?!i&&"Invalid city code":"Invalid bank code":"Must be only numeric digits (no letters)";return{error:!!r,message:r||"Valid: "+l+" ("+i+")",bank:l,city:i}},calculate:function(a,e,o){function n(a,e){return function a(e,o){return e.length<o?a("0"+e,o):e}(""+a,e).slice(-e)}var l=n(a,3)+n(e,3)+n(o,11);return l+clabe.calcChecksum(l)},bank:{2:"Banco Nacional de México",6:"Banco Nacional de Comercio Exterior",9:"Banco Nacional de Obras y Servicios Públicos",12:"BBVA Bancomer",14:"Banco Santander",19:"Banco Nacional del Ejército",21:"HSBC México",22:"GE Money Bank",30:"Banco del Bajío",32:"IXE Banco",36:"Banco Inbursa",37:"Banco Interacciones",42:"Banca Mifel",44:"Scotiabank Inverlat",58:"Banco Regional de Monterrey",59:"Banco Invex",60:"Bansi",62:"Banca Afirme",72:"Banco Mercantil del Norte",102:"ABN AMRO Bank México",103:"American Express Bank (México)",106:"Bank of America México",108:"Bank of Tokyo-Mitsubishi UFJ (México)",110:"Banco J.P. Morgan",112:"Banco Monex",113:"Banco Ve por Mas",116:"ING Bank (México)",124:"Deutsche Bank México",126:"Banco Credit Suisse (México)",127:"Banco Azteca",128:"Banco Autofin México",129:"Barclays Bank México",130:"Banco Compartamos",131:"Banco Ahorro Famsa",132:"Banco Multiva",133:"Prudencial Bank",134:"Banco Wal Mart de México Adelante",135:"Nacional Financiera",136:"Banco Regional",137:"BanCoppel",138:"Banco Amigo",139:"UBS Banco",140:"Banco Fácil",141:"Volkswagen Bank",143:"Consultoría Internacional Banco",145:"Banco BASE de I.B.M.",147:"Bankaool, Institución de Banca Múltiple",150:"Banco Inmobiliario Mexicano",156:"Banco Sabadell, S.A. I.B.M.",166:"Banco del Ahorro Nacional y Servicios Financieros",168:"Sociedad Hipotecaria Federal",600:"Monex Casa de Bolsa",601:"GBM Grupo Bursátil Mexicano",602:"Masari Casa de Cambio",604:"Inversora Bursátil",605:"Valué, Casa de Bolsa",606:"Base Internacional Casa de Bolsa",607:"Casa de Cambio Tiber",608:"Vector Casa de Bolsa",610:"B y B Casa de Cambio",611:"Intercam Casa de Cambio",613:"Multivalores Casa de Bolsa Multiva Gpo. Fin.",614:"Acciones y Valores Banamex",615:"Merrill Lynch México",616:"Casa de Bolsa Finamex",617:"Valores Mexicanos",618:"Única Casa de Cambio",619:"MAPFRE Tepeyac",620:"Profuturo G.N.P.",621:"Actinver Casa de Bolsa",622:"Actinver",623:"Skandia Vida",624:"Consultoría Internacional Casa de Cambio",626:"Deutsche Securities, S.A. de C.V.",627:"Zurich Compañía de Seguros",628:"Zurich Vida, Compañía de Seguros",629:"Hipotecaria su Casita",630:"Intercam Casa de Bolsa",631:"Vanguardia Casa de Bolsa",632:"Bulltick Casa de Bolsa",633:"Sterling Casa de Cambio",634:"Fincomún, Servicios Financieros Comunitarios",636:"HDI Seguros, S.A. de C.V.",637:"OrderExpress Casa de Cambio AAC",638:"Akala, Sociedad Financiera Popular",640:"J.P. Morgan Casa de Bolsa",642:"Operadora de Recursos Reforma, S.A. de C.V.",646:"Sistema de Transferencias y Pagos STP",647:"Telecomunicaciones de México",648:"Evercore Casa de Bolsa, S.A. de C.V.",649:"Skandia Operadora",651:"Seguros Monterrey New York Life, S.A de C.V.",652:"Solución Asea, S.A. de C.V., Sociedad Financiera Popular",653:"Kuspit Casa de Bolsa, S.A. de C.V.",655:"J.P. SOFIEXPRESS, S.A. de C.V., S.F.P.",656:"UNAGRA, S.A. de C.V., S.F.P.",659:"Opciones Empresariales Del Noreste, S.A. DE C.V.",670:"Libertad Servicios Financieros, S.A. De C.V.",901:"CLS Bank International",902:"SD. INDEVAL",999:"N/A"},cities:[[10,"Aguascalientes"],[12,"Calvillo"],[14,"Jesús María"],[20,"Mexicali"],[22,"Ensenada"],[27,"Tecate"],[27,"Tijuana"],[28,"La Mesa"],[28,"Rosarito"],[28,"Tijuana [alternate]"],[40,"La Paz"],[41,"Cabo San Lucas"],[42,"Ciudad Constitución"],[43,"Guerrero Negro"],[45,"San José del Cabo"],[46,"Santa Rosalía"],[50,"Campeche"],[51,"Calkiní"],[52,"Ciudad del Carmen"],[53,"Champotón"],[60,"Gómez Palacio"],[60,"Torreón"],[62,"Ciudad Acuña"],[68,"Monclova"],[71,"Nava"],[72,"Nueva Rosita"],[74,"Parras de la Fuente"],[75,"Piedras Negras"],[76,"Ramos Arizpe"],[77,"Sabinas"],[78,"Saltillo"],[80,"San Pedro de las Colonias"],[90,"Colima"],[95,"Manzanillo"],[97,"Tecomán"],[100,"Terán"],[100,"Tuxtla Gutiérrez"],[103,"Arriaga"],[107,"Cintalapa"],[109,"Comitán"],[109,"Villa Las Rosas"],[111,"Chiapa de Corso"],[113,"F. Comalapa"],[114,"Huixtla"],[123,"Ocosingo"],[124,"Ocozocuautla"],[125,"Palenque"],[126,"Pichucalco"],[127,"Pijijiapan"],[128,"Reforma"],[130,"San Cristóbal de las Casas"],[131,"Simojovel"],[133,"Tapachula"],[135,"Tonala"],[137,"Venustiano Carranza"],[138,"Villa Flores"],[140,"Yajalón"],[150,"Chihuahua"],[150,"Ciudad Delicias"],[152,"Ciudad Anáhuac"],[155,"Ciudad Camargo"],[158,"Ciudad Cuauhtémoc"],[161,"Ciudad Guerrero"],[162,"Parral"],[163,"Ciudad Jiménez"],[164,"Ciudad Juárez"],[165,"Ciudad Madera"],[167,"El Molino de Namiquipa"],[168,"Nuevo Casas Grandes"],[180,"Atizapan"],[180,"Chalco"],[180,"Ciudad de México"],[180,"Coacalco"],[180,"Cuautitlán Izcalli"],[180,"Cuautitlán"],[180,"Ecatepec"],[180,"Huehuetoca"],[180,"Huixquilucan"],[180,"Ixtapaluca"],[180,"Los Reyes La Paz"],[180,"Naucalpan"],[180,"Nezahualcóyotl"],[180,"Tecamac"],[180,"Teotihuacán"],[180,"Texcoco"],[180,"Tlalnepantla"],[190,"Durango"],[201,"Tepehuanes"],[202,"Vicente Guerrero"],[210,"Guanajuato"],[211,"Abasolo"],[212,"Acámbaro"],[213,"Apaseo el Alto"],[214,"Apaseo el Grande"],[215,"Celaya"],[216,"Comonfort"],[217,"Coroneo"],[218,"Cortazar"],[219,"Cuerámaro"],[220,"Dolores Hidalgo"],[222,"Irapuato"],[223,"Jaral del Progreso"],[224,"Jerécuaro"],[225,"León"],[226,"Cd. Manuel Doblado"],[227,"Moroleón"],[229,"Pénjamo"],[232,"Romita"],[233,"Salamanca"],[234,"Salvatierra"],[236,"San Felipe"],[237,"Purísima de Bustos"],[237,"San Francisco del Rincoón"],[238,"San José Iturbide"],[239,"San Luis de la Paz"],[240,"San Miguel Allende"],[244,"Silao"],[247,"Uriangato"],[248,"Valle de Santiago"],[249,"Yuriria"],[260,"Chilpancingo"],[261,"Acapulco"],[263,"Arcelia"],[264,"Atoyac de Álvarez"],[266,"Ciudad Altamirano"],[267,"Coyuca de Benítez"],[270,"Chilapa"],[271,"Huitzuco"],[272,"Iguala"],[272,"La Sabana"],[274,"Cuajinicuilapa"],[274,"Ometepec"],[275,"San Marcos"],[276,"Taxco"],[278,"Teloloapan"],[281,"Tlapa"],[282,"Ixtapa Zihuatanejo"],[282,"Zihuatanejo"],[290,"Pachuca"],[291,"Actopan"],[292,"Apam"],[293,"Atotonilco el Grande"],[294,"Ciudad Sahagún"],[294,"Teocaltiche"],[295,"Cuautepec"],[296,"Huejutla"],[297,"Huichapan"],[298,"Ixmiquilpan"],[303,"Progreso de Obregón"],[305,"Tepeapulco"],[308,"Tizayuca"],[311,"Tula de Allende"],[312,"Tulancingo"],[313,"Zacualtipán"],[314,"Zimapán"],[320,"El Salto"],[320,"Guadalajara"],[320,"San Pedro Tlaquepaque"],[320,"Tlajomulco"],[320,"Tonala [alternate]"],[320,"Zapopan"],[326,"Ameca"],[327,"Arandas"],[330,"Atotonilco el Alto"],[331,"Atequiza"],[333,"Autlán"],[334,"Azteca"],[340,"Casimiro Castillo"],[341,"Cihuatlán"],[342,"Ciudad Guzmán"],[346,"Chapala"],[348,"El Grullo"],[355,"Ixtlahuacán del Río"],[356,"Jalostotitlán"],[357,"Jamay"],[361,"La Barca"],[362,"Lagos de Moreno"],[370,"Ocotlán"],[373,"Pihuamo"],[375,"Las Juntas"],[375,"Nuevo Vallarta"],[375,"Pitillal"],[375,"Puerto Vallarta"],[381,"San Juan de los Lagos"],[384,"San Miguel el Alto"],[385,"San Patricio Melaque"],[386,"Sayula"],[387,"Tala"],[389,"Tamazula de Gordiano"],[391,"Tecalitlán"],[396,"Tepatitlán"],[397,"Tequila"],[403,"Tototlán"],[404,"Túxpam"],[411,"Villa Hidalgo"],[413,"Zacoalco de Torres"],[414,"Zapotiltic"],[416,"Zapotlanejo"],[420,"Toluca"],[421,"Acambay"],[422,"Almoloya de Juárez"],[424,"Amecameca"],[425,"Apaxco"],[426,"Atlacomulco"],[428,"Coatepec de Harinas"],[430,"Chicoloapan"],[431,"Chiconcuac"],[432,"El Oro"],[433,"Ixtapan de la Sal"],[434,"Ixtlahuaca"],[435,"Jilotepec"],[438,"Lerma"],[441,"Metepec"],[443,"Otumba"],[445,"San Mateo Atenco"],[446,"Tejupilco"],[448,"Temascaltepec"],[449,"Temoaya"],[450,"Tenancingo"],[451,"Tenago del Valle"],[453,"Santiago Tiangistenco"],[455,"Tultepec"],[456,"Tultitlán"],[457,"Valle de Bravo"],[460,"Villa Nicolás Romero"],[463,"Zumpango"],[470,"Morelia"],[472,"Aguililla"],[476,"Apatzingán"],[480,"Ciudad Hidalgo"],[483,"Cotija"],[484,"Cuitzeo"],[492,"Huetamo"],[493,"Jacona"],[494,"Jiquilpan"],[496,"La Piedad"],[497,"Lázaro Cárdenas"],[498,"Los Reyes"],[499,"Maravatío"],[501,"Nueva Italia"],[506,"Pátzcuaro"],[508,"Purépero"],[509,"Puruandiro"],[512,"Sahuayo"],[515,"Tacámbaro"],[517,"Tangancícuaro"],[519,"Tepalcatepec"],[523,"Tlazazalca"],[528,"Uruapan"],[533,"Yurécuaro"],[534,"Zacapu"],[535,"Zamora"],[536,"Zinapécuaro"],[537,"Zitácuaro"],[540,"Cuernavaca"],[542,"Cuautla"],[542,"Oaxtepec, Morelos"],[543,"Jiutepec"],[544,"Jojutla"],[545,"Puente de Ixtla"],[546,"Temixco"],[548,"Tetecala"],[549,"Yautepec"],[552,"Zacatepec"],[560,"Tepic"],[561,"Acaponeta"],[562,"Ahuacatlán"],[564,"Compostela"],[566,"Ixtlán del Río"],[571,"San Blas"],[573,"Santiago Ixcuintla"],[575,"Túxpam [alternate]"],[580,"Apodaca"],[580,"Cadereyta"],[580,"Cd. Guadalupe"],[580,"General Escobedo"],[580,"Monterrey"],[580,"San Nicolás de los Garza"],[580,"San Pedro Garza García"],[580,"Santa Catarina"],[583,"Allende"],[592,"General Zuazua"],[595,"Linares"],[597,"Montemorelos"],[599,"Sabinas Hidalgo"],[600,"Salinas Victoria"],[601,"El Cercado"],[601,"Villa de Santiago"],[610,"Oaxaca"],[613,"Tlaxiaco"],[614,"Huajuapan de León"],[616,"Ixtepec"],[617,"Juchitán"],[619,"Loma Bonita"],[620,"Matías Romero"],[621,"Miahuatlán"],[622,"Ocotlán [alternate]"],[624,"Puerto Escondido"],[626,"Salina Cruz"],[627,"Lagunas"],[628,"Tuxtepec"],[630,"Pochutla"],[631,"San Pedro Tapanatepec"],[632,"Santa Lucía del Camino"],[634,"Bahías de Huatulco"],[635,"Santiago Juxtlahuaca"],[636,"Pinotepa Nacional"],[637,"Tehuantepec"],[638,"Tlacolula"],[640,"Zimatlán"],[650,"Cholula"],[650,"La Resurrección"],[650,"Puebla"],[650,"San Baltazar Campeche"],[651,"N/A"],[652,"Acatzingo"],[654,"Atlixco"],[656,"Cuetzalan"],[659,"Huauchinango"],[662,"Izúcar de Matamoros"],[667,"San Martín Texmelucan"],[668,"San Felipe Hueyotlipan"],[669,"Tecamachalco"],[670,"Tehuacán"],[671,"San Lorenzo"],[672,"Teziutlán"],[674,"Xicotepec de Juárez"],[676,"Zacatlán"],[680,"Pedro Escobedo"],[680,"Querétaro"],[680,"Villa Corregidora"],[681,"Amealco"],[685,"San Juan del Río"],[686,"Tequisquiapan"],[690,"Chetumal"],[691,"Cancún"],[691,"Col. Puerto Juárez"],[692,"Cozumel"],[693,"N/A"],[694,"Playa del Carmen"],[700,"San Luis Potosí"],[703,"Cerritos"],[705,"Ciudad Valles"],[709,"Matehuala"],[711,"Río Verde"],[716,"Tamuín"],[730,"Culiacán"],[735,"Concordia"],[736,"Cosala"],[737,"Choix"],[738,"El Fuerte"],[739,"Escuinapa"],[740,"Guamúchil"],[741,"Guasave"],[743,"Los Mochis"],[743,"Topolobampo"],[744,"Mazatlán"],[745,"Mocorito"],[746,"Navolato"],[760,"Hermosillo"],[761,"Agua Prieta"],[765,"Caborca"],[766,"Cananea"],[767,"Ciudad Obregón"],[767,"Esperanza"],[769,"Empalme"],[770,"Guaymas"],[770,"San Carlos"],[771,"Huatabampo"],[773,"Magdalena"],[776,"Nacozari de García"],[777,"Navojoa"],[778,"Nogales"],[779,"Puerto Peñasco"],[780,"San Luis Río Colorado"],[790,"Tamulte"],[790,"Villa Hermosa"],[792,"Cárdenas"],[793,"Ciudad Pemex"],[794,"Comalcalco"],[796,"Emiliano Zapata"],[797,"Frontera"],[798,"Huimanguillo"],[800,"Jalpa de Méndez"],[802,"Macuspana"],[803,"Nacajuca"],[804,"Paraíso"],[805,"Tacotalpa"],[806,"Teapa"],[807,"Tenosique"],[810,"Ciudad Victoria"],[811,"Altamira"],[813,"Ciudad Madero"],[813,"Tampico"],[814,"Ciudad Mante"],[818,"Matamoros"],[821,"Colombia"],[821,"Nuevo Laredo"],[822,"Reynosa"],[823,"Río Bravo"],[825,"Soto La Marina"],[826,"Valle Hermoso"],[830,"Tlaxcala"],[832,"Apizaco"],[834,"Santa Ana Chiautempan"],[840,"Jalapa"],[841,"Acayucan"],[843,"Agua Dulce"],[845,"Álamo"],[846,"Altotonga"],[848,"Banderilla"],[849,"Boca del Río"],[852,"Ciudad Mendoza"],[853,"Coatepec"],[854,"Coatzacoalcos"],[855,"Córdoba"],[856,"Cosamaloapan"],[860,"Cuitláhuac"],[863,"Fortín de las Flores"],[864,"Gutiérrez Zamora"],[865,"Huatusco"],[867,"Isla"],[868,"Ixtaczoquitlán"],[869,"Jáltipan"],[871,"Juan Rodríguez Clara"],[872,"Villa José Cardel"],[873,"Las Choapas"],[875,"Naranjos"],[876,"Martínez de la Torre"],[877,"Minatitlán"],[878,"Misantla"],[879,"Nanchital"],[882,"Orizaba"],[885,"Papantla"],[886,"Perote"],[888,"Poza Rica"],[889,"Río Blanco"],[890,"San Andrés Tuxtla"],[891,"San Rafael"],[894,"Platón Sánchez"],[894,"Tantoyuca"],[895,"Tempoal"],[898,"Tierra Blanca"],[901,"Tlapacoyan"],[903,"Túxpam de Rodríguez Cano"],[905,"Cd. Industrial Framboyan"],[905,"Veracruz"],[910,"Mérida"],[913,"Motul"],[914,"Oxkutzcab"],[915,"Progreso"],[917,"Ticul"],[918,"Tizimín"],[920,"Valladolid"],[930,"Zacatecas"],[933,"Fresnillo"],[934,"Guadalupe"],[935,"Jalpa"],[936,"Jerez de G. Salinas"],[938,"Juchipila"],[939,"Loreto"],[946,"Nochistlán"],[958,"Valparaíso"],[960,"Calera de V. Rosales"]]};"object"==typeof module&&(module.exports=clabe);
//! CLABE Validator v1.0.4 ~ github.com/center-key/clabe-validator ~ MIT License
var clabe={version:"1.0.4",calcChecksum:function(a){var o=0;return a.split("").slice(0,17).forEach(function(a,e){o+=parseInt(a)*[3,7,1][e%3]%10}),(10-o%10)%10},validate:function(a){if("string"!=typeof a)throw"clabe.validator.check(clabeNum) -- Expected string, got: "+typeof a;var e=a.substr(0,3),o=a.substr(3,3),n=parseInt(a.substr(17,1));clabe.citiesMap||(clabe.citiesMap={},clabe.cities.forEach(function(a){var e;clabe.citiesMap[a[0]]=(e=a[0],(clabe.citiesMap[e]?clabe.citiesMap[e]+", ":"")+a[1])}));var l=clabe.banksMap[parseInt(e)],i=clabe.citiesMap[parseInt(o)];function c(){return clabe.calcChecksum(a)}var r=18!==a.length?"Must be exactly 18 digits long":/[0-9]{18}/.test(a)?c()!==n?"Invalid checksum, last digit should be: "+c():l?!i&&"Invalid city code":"Invalid bank code":"Must be only numeric digits (no letters)";return{error:!!r,message:r||"Valid: "+l+" ("+i+")",bank:l,city:i}},calculate:function(a,e,o){function n(a,e){return function a(e,o){return e.length<o?a("0"+e,o):e}(""+a,e).slice(-e)}var l=n(a,3)+n(e,3)+n(o,11);return l+clabe.calcChecksum(l)},banksMap:{2:"Banco Nacional de México",6:"Banco Nacional de Comercio Exterior",9:"Banco Nacional de Obras y Servicios Públicos",12:"BBVA Bancomer",14:"Banco Santander",19:"Banco Nacional del Ejército",21:"HSBC México",22:"GE Money Bank",30:"Banco del Bajío",32:"IXE Banco",36:"Banco Inbursa",37:"Banco Interacciones",42:"Banca Mifel",44:"Scotiabank Inverlat",58:"Banco Regional de Monterrey",59:"Banco Invex",60:"Bansi",62:"Banca Afirme",72:"Banco Mercantil del Norte",102:"ABN AMRO Bank México",103:"American Express Bank (México)",106:"Bank of America México",108:"Bank of Tokyo-Mitsubishi UFJ (México)",110:"Banco J.P. Morgan",112:"Banco Monex",113:"Banco Ve por Mas",116:"ING Bank (México)",124:"Deutsche Bank México",126:"Banco Credit Suisse (México)",127:"Banco Azteca",128:"Banco Autofin México",129:"Barclays Bank México",130:"Banco Compartamos",131:"Banco Ahorro Famsa",132:"Banco Multiva",133:"Prudencial Bank",134:"Banco Wal Mart de México Adelante",135:"Nacional Financiera",136:"Banco Regional",137:"BanCoppel",138:"Banco Amigo",139:"UBS Banco",140:"Banco Fácil",141:"Volkswagen Bank",143:"Consultoría Internacional Banco",145:"Banco BASE de I.B.M.",147:"Bankaool, Institución de Banca Múltiple",150:"Banco Inmobiliario Mexicano",156:"Banco Sabadell, S.A. I.B.M.",166:"Banco del Ahorro Nacional y Servicios Financieros",168:"Sociedad Hipotecaria Federal",600:"Monex Casa de Bolsa",601:"GBM Grupo Bursátil Mexicano",602:"Masari Casa de Cambio",604:"Inversora Bursátil",605:"Valué, Casa de Bolsa",606:"Base Internacional Casa de Bolsa",607:"Casa de Cambio Tiber",608:"Vector Casa de Bolsa",610:"B y B Casa de Cambio",611:"Intercam Casa de Cambio",613:"Multivalores Casa de Bolsa Multiva Gpo. Fin.",614:"Acciones y Valores Banamex",615:"Merrill Lynch México",616:"Casa de Bolsa Finamex",617:"Valores Mexicanos",618:"Única Casa de Cambio",619:"MAPFRE Tepeyac",620:"Profuturo G.N.P.",621:"Actinver Casa de Bolsa",622:"Actinver",623:"Skandia Vida",624:"Consultoría Internacional Casa de Cambio",626:"Deutsche Securities, S.A. de C.V.",627:"Zurich Compañía de Seguros",628:"Zurich Vida, Compañía de Seguros",629:"Hipotecaria su Casita",630:"Intercam Casa de Bolsa",631:"Vanguardia Casa de Bolsa",632:"Bulltick Casa de Bolsa",633:"Sterling Casa de Cambio",634:"Fincomún, Servicios Financieros Comunitarios",636:"HDI Seguros, S.A. de C.V.",637:"OrderExpress Casa de Cambio AAC",638:"Akala, Sociedad Financiera Popular",640:"J.P. Morgan Casa de Bolsa",642:"Operadora de Recursos Reforma, S.A. de C.V.",646:"Sistema de Transferencias y Pagos STP",647:"Telecomunicaciones de México",648:"Evercore Casa de Bolsa, S.A. de C.V.",649:"Skandia Operadora",651:"Seguros Monterrey New York Life, S.A de C.V.",652:"Solución Asea, S.A. de C.V., Sociedad Financiera Popular",653:"Kuspit Casa de Bolsa, S.A. de C.V.",655:"J.P. SOFIEXPRESS, S.A. de C.V., S.F.P.",656:"UNAGRA, S.A. de C.V., S.F.P.",659:"Opciones Empresariales Del Noreste, S.A. DE C.V.",670:"Libertad Servicios Financieros, S.A. De C.V.",901:"CLS Bank International",902:"SD. INDEVAL",999:"N/A"},cities:[[10,"Aguascalientes"],[12,"Calvillo"],[14,"Jesús María"],[20,"Mexicali"],[22,"Ensenada"],[27,"Tecate"],[27,"Tijuana"],[28,"La Mesa"],[28,"Rosarito"],[28,"Tijuana [alternate]"],[40,"La Paz"],[41,"Cabo San Lucas"],[42,"Ciudad Constitución"],[43,"Guerrero Negro"],[45,"San José del Cabo"],[46,"Santa Rosalía"],[50,"Campeche"],[51,"Calkiní"],[52,"Ciudad del Carmen"],[53,"Champotón"],[60,"Gómez Palacio"],[60,"Torreón"],[62,"Ciudad Acuña"],[68,"Monclova"],[71,"Nava"],[72,"Nueva Rosita"],[74,"Parras de la Fuente"],[75,"Piedras Negras"],[76,"Ramos Arizpe"],[77,"Sabinas"],[78,"Saltillo"],[80,"San Pedro de las Colonias"],[90,"Colima"],[95,"Manzanillo"],[97,"Tecomán"],[100,"Terán"],[100,"Tuxtla Gutiérrez"],[103,"Arriaga"],[107,"Cintalapa"],[109,"Comitán"],[109,"Villa Las Rosas"],[111,"Chiapa de Corso"],[113,"F. Comalapa"],[114,"Huixtla"],[123,"Ocosingo"],[124,"Ocozocuautla"],[125,"Palenque"],[126,"Pichucalco"],[127,"Pijijiapan"],[128,"Reforma"],[130,"San Cristóbal de las Casas"],[131,"Simojovel"],[133,"Tapachula"],[135,"Tonala"],[137,"Venustiano Carranza"],[138,"Villa Flores"],[140,"Yajalón"],[150,"Chihuahua"],[150,"Ciudad Delicias"],[152,"Ciudad Anáhuac"],[155,"Ciudad Camargo"],[158,"Ciudad Cuauhtémoc"],[161,"Ciudad Guerrero"],[162,"Parral"],[163,"Ciudad Jiménez"],[164,"Ciudad Juárez"],[165,"Ciudad Madera"],[167,"El Molino de Namiquipa"],[168,"Nuevo Casas Grandes"],[180,"Atizapan"],[180,"Chalco"],[180,"Ciudad de México"],[180,"Coacalco"],[180,"Cuautitlán Izcalli"],[180,"Cuautitlán"],[180,"Ecatepec"],[180,"Huehuetoca"],[180,"Huixquilucan"],[180,"Ixtapaluca"],[180,"Los Reyes La Paz"],[180,"Naucalpan"],[180,"Nezahualcóyotl"],[180,"Tecamac"],[180,"Teotihuacán"],[180,"Texcoco"],[180,"Tlalnepantla"],[190,"Durango"],[201,"Tepehuanes"],[202,"Vicente Guerrero"],[210,"Guanajuato"],[211,"Abasolo"],[212,"Acámbaro"],[213,"Apaseo el Alto"],[214,"Apaseo el Grande"],[215,"Celaya"],[216,"Comonfort"],[217,"Coroneo"],[218,"Cortazar"],[219,"Cuerámaro"],[220,"Dolores Hidalgo"],[222,"Irapuato"],[223,"Jaral del Progreso"],[224,"Jerécuaro"],[225,"León"],[226,"Cd. Manuel Doblado"],[227,"Moroleón"],[229,"Pénjamo"],[232,"Romita"],[233,"Salamanca"],[234,"Salvatierra"],[236,"San Felipe"],[237,"Purísima de Bustos"],[237,"San Francisco del Rincoón"],[238,"San José Iturbide"],[239,"San Luis de la Paz"],[240,"San Miguel Allende"],[244,"Silao"],[247,"Uriangato"],[248,"Valle de Santiago"],[249,"Yuriria"],[260,"Chilpancingo"],[261,"Acapulco"],[263,"Arcelia"],[264,"Atoyac de Álvarez"],[266,"Ciudad Altamirano"],[267,"Coyuca de Benítez"],[270,"Chilapa"],[271,"Huitzuco"],[272,"Iguala"],[272,"La Sabana"],[274,"Cuajinicuilapa"],[274,"Ometepec"],[275,"San Marcos"],[276,"Taxco"],[278,"Teloloapan"],[281,"Tlapa"],[282,"Ixtapa Zihuatanejo"],[282,"Zihuatanejo"],[290,"Pachuca"],[291,"Actopan"],[292,"Apam"],[293,"Atotonilco el Grande"],[294,"Ciudad Sahagún"],[294,"Teocaltiche"],[295,"Cuautepec"],[296,"Huejutla"],[297,"Huichapan"],[298,"Ixmiquilpan"],[303,"Progreso de Obregón"],[305,"Tepeapulco"],[308,"Tizayuca"],[311,"Tula de Allende"],[312,"Tulancingo"],[313,"Zacualtipán"],[314,"Zimapán"],[320,"El Salto"],[320,"Guadalajara"],[320,"San Pedro Tlaquepaque"],[320,"Tlajomulco"],[320,"Tonala [alternate]"],[320,"Zapopan"],[326,"Ameca"],[327,"Arandas"],[330,"Atotonilco el Alto"],[331,"Atequiza"],[333,"Autlán"],[334,"Azteca"],[340,"Casimiro Castillo"],[341,"Cihuatlán"],[342,"Ciudad Guzmán"],[346,"Chapala"],[348,"El Grullo"],[355,"Ixtlahuacán del Río"],[356,"Jalostotitlán"],[357,"Jamay"],[361,"La Barca"],[362,"Lagos de Moreno"],[370,"Ocotlán"],[373,"Pihuamo"],[375,"Las Juntas"],[375,"Nuevo Vallarta"],[375,"Pitillal"],[375,"Puerto Vallarta"],[381,"San Juan de los Lagos"],[384,"San Miguel el Alto"],[385,"San Patricio Melaque"],[386,"Sayula"],[387,"Tala"],[389,"Tamazula de Gordiano"],[391,"Tecalitlán"],[396,"Tepatitlán"],[397,"Tequila"],[403,"Tototlán"],[404,"Túxpam"],[411,"Villa Hidalgo"],[413,"Zacoalco de Torres"],[414,"Zapotiltic"],[416,"Zapotlanejo"],[420,"Toluca"],[421,"Acambay"],[422,"Almoloya de Juárez"],[424,"Amecameca"],[425,"Apaxco"],[426,"Atlacomulco"],[428,"Coatepec de Harinas"],[430,"Chicoloapan"],[431,"Chiconcuac"],[432,"El Oro"],[433,"Ixtapan de la Sal"],[434,"Ixtlahuaca"],[435,"Jilotepec"],[438,"Lerma"],[441,"Metepec"],[443,"Otumba"],[445,"San Mateo Atenco"],[446,"Tejupilco"],[448,"Temascaltepec"],[449,"Temoaya"],[450,"Tenancingo"],[451,"Tenago del Valle"],[453,"Santiago Tiangistenco"],[455,"Tultepec"],[456,"Tultitlán"],[457,"Valle de Bravo"],[460,"Villa Nicolás Romero"],[463,"Zumpango"],[470,"Morelia"],[472,"Aguililla"],[476,"Apatzingán"],[480,"Ciudad Hidalgo"],[483,"Cotija"],[484,"Cuitzeo"],[492,"Huetamo"],[493,"Jacona"],[494,"Jiquilpan"],[496,"La Piedad"],[497,"Lázaro Cárdenas"],[498,"Los Reyes"],[499,"Maravatío"],[501,"Nueva Italia"],[506,"Pátzcuaro"],[508,"Purépero"],[509,"Puruandiro"],[512,"Sahuayo"],[515,"Tacámbaro"],[517,"Tangancícuaro"],[519,"Tepalcatepec"],[523,"Tlazazalca"],[528,"Uruapan"],[533,"Yurécuaro"],[534,"Zacapu"],[535,"Zamora"],[536,"Zinapécuaro"],[537,"Zitácuaro"],[540,"Cuernavaca"],[542,"Cuautla"],[542,"Oaxtepec, Morelos"],[543,"Jiutepec"],[544,"Jojutla"],[545,"Puente de Ixtla"],[546,"Temixco"],[548,"Tetecala"],[549,"Yautepec"],[552,"Zacatepec"],[560,"Tepic"],[561,"Acaponeta"],[562,"Ahuacatlán"],[564,"Compostela"],[566,"Ixtlán del Río"],[571,"San Blas"],[573,"Santiago Ixcuintla"],[575,"Túxpam [alternate]"],[580,"Apodaca"],[580,"Cadereyta"],[580,"Cd. Guadalupe"],[580,"General Escobedo"],[580,"Monterrey"],[580,"San Nicolás de los Garza"],[580,"San Pedro Garza García"],[580,"Santa Catarina"],[583,"Allende"],[592,"General Zuazua"],[595,"Linares"],[597,"Montemorelos"],[599,"Sabinas Hidalgo"],[600,"Salinas Victoria"],[601,"El Cercado"],[601,"Villa de Santiago"],[610,"Oaxaca"],[613,"Tlaxiaco"],[614,"Huajuapan de León"],[616,"Ixtepec"],[617,"Juchitán"],[619,"Loma Bonita"],[620,"Matías Romero"],[621,"Miahuatlán"],[622,"Ocotlán [alternate]"],[624,"Puerto Escondido"],[626,"Salina Cruz"],[627,"Lagunas"],[628,"Tuxtepec"],[630,"Pochutla"],[631,"San Pedro Tapanatepec"],[632,"Santa Lucía del Camino"],[634,"Bahías de Huatulco"],[635,"Santiago Juxtlahuaca"],[636,"Pinotepa Nacional"],[637,"Tehuantepec"],[638,"Tlacolula"],[640,"Zimatlán"],[650,"Cholula"],[650,"La Resurrección"],[650,"Puebla"],[650,"San Baltazar Campeche"],[651,"N/A"],[652,"Acatzingo"],[654,"Atlixco"],[656,"Cuetzalan"],[659,"Huauchinango"],[662,"Izúcar de Matamoros"],[667,"San Martín Texmelucan"],[668,"San Felipe Hueyotlipan"],[669,"Tecamachalco"],[670,"Tehuacán"],[671,"San Lorenzo"],[672,"Teziutlán"],[674,"Xicotepec de Juárez"],[676,"Zacatlán"],[680,"Pedro Escobedo"],[680,"Querétaro"],[680,"Villa Corregidora"],[681,"Amealco"],[685,"San Juan del Río"],[686,"Tequisquiapan"],[690,"Chetumal"],[691,"Cancún"],[691,"Col. Puerto Juárez"],[692,"Cozumel"],[693,"N/A"],[694,"Playa del Carmen"],[700,"San Luis Potosí"],[703,"Cerritos"],[705,"Ciudad Valles"],[709,"Matehuala"],[711,"Río Verde"],[716,"Tamuín"],[730,"Culiacán"],[735,"Concordia"],[736,"Cosala"],[737,"Choix"],[738,"El Fuerte"],[739,"Escuinapa"],[740,"Guamúchil"],[741,"Guasave"],[743,"Los Mochis"],[743,"Topolobampo"],[744,"Mazatlán"],[745,"Mocorito"],[746,"Navolato"],[760,"Hermosillo"],[761,"Agua Prieta"],[765,"Caborca"],[766,"Cananea"],[767,"Ciudad Obregón"],[767,"Esperanza"],[769,"Empalme"],[770,"Guaymas"],[770,"San Carlos"],[771,"Huatabampo"],[773,"Magdalena"],[776,"Nacozari de García"],[777,"Navojoa"],[778,"Nogales"],[779,"Puerto Peñasco"],[780,"San Luis Río Colorado"],[790,"Tamulte"],[790,"Villa Hermosa"],[792,"Cárdenas"],[793,"Ciudad Pemex"],[794,"Comalcalco"],[796,"Emiliano Zapata"],[797,"Frontera"],[798,"Huimanguillo"],[800,"Jalpa de Méndez"],[802,"Macuspana"],[803,"Nacajuca"],[804,"Paraíso"],[805,"Tacotalpa"],[806,"Teapa"],[807,"Tenosique"],[810,"Ciudad Victoria"],[811,"Altamira"],[813,"Ciudad Madero"],[813,"Tampico"],[814,"Ciudad Mante"],[818,"Matamoros"],[821,"Colombia"],[821,"Nuevo Laredo"],[822,"Reynosa"],[823,"Río Bravo"],[825,"Soto La Marina"],[826,"Valle Hermoso"],[830,"Tlaxcala"],[832,"Apizaco"],[834,"Santa Ana Chiautempan"],[840,"Jalapa"],[841,"Acayucan"],[843,"Agua Dulce"],[845,"Álamo"],[846,"Altotonga"],[848,"Banderilla"],[849,"Boca del Río"],[852,"Ciudad Mendoza"],[853,"Coatepec"],[854,"Coatzacoalcos"],[855,"Córdoba"],[856,"Cosamaloapan"],[860,"Cuitláhuac"],[863,"Fortín de las Flores"],[864,"Gutiérrez Zamora"],[865,"Huatusco"],[867,"Isla"],[868,"Ixtaczoquitlán"],[869,"Jáltipan"],[871,"Juan Rodríguez Clara"],[872,"Villa José Cardel"],[873,"Las Choapas"],[875,"Naranjos"],[876,"Martínez de la Torre"],[877,"Minatitlán"],[878,"Misantla"],[879,"Nanchital"],[882,"Orizaba"],[885,"Papantla"],[886,"Perote"],[888,"Poza Rica"],[889,"Río Blanco"],[890,"San Andrés Tuxtla"],[891,"San Rafael"],[894,"Platón Sánchez"],[894,"Tantoyuca"],[895,"Tempoal"],[898,"Tierra Blanca"],[901,"Tlapacoyan"],[903,"Túxpam de Rodríguez Cano"],[905,"Cd. Industrial Framboyan"],[905,"Veracruz"],[910,"Mérida"],[913,"Motul"],[914,"Oxkutzcab"],[915,"Progreso"],[917,"Ticul"],[918,"Tizimín"],[920,"Valladolid"],[930,"Zacatecas"],[933,"Fresnillo"],[934,"Guadalupe"],[935,"Jalpa"],[936,"Jerez de G. Salinas"],[938,"Juchipila"],[939,"Loreto"],[946,"Nochistlán"],[958,"Valparaíso"],[960,"Calera de V. Rosales"]]};"object"==typeof module&&(module.exports=clabe);

@@ -5,52 +5,55 @@ // CLABE Validator

const gulp = require('gulp');
const header = require('gulp-header');
const htmlHint = require('gulp-htmlhint');
const jshint = require('gulp-jshint');
const rename = require('gulp-rename');
const replace = require('gulp-replace');
const size = require('gulp-size');
const uglify = require('gulp-uglify');
const w3cJs = require('gulp-w3cjs');
// Imports
const gulp = require('gulp');
const header = require('gulp-header');
const htmlHint = require('gulp-htmlhint');
const jshint = require('gulp-jshint');
const rename = require('gulp-rename');
const replace = require('gulp-replace');
const size = require('gulp-size');
const uglify = require('gulp-uglify');
const w3cHtmlValidator = require('gulp-w3cjs');
const pkg = require('./package.json');
const home = pkg.homepage.replace('https://', '');
const banner = '//CLABE Validator v' + [pkg.version, home, pkg.license].join(' ~ ') + '\n';
// Setup
const pkg = require('./package.json');
const home = pkg.homepage.replace('https://', '');
const license = pkg.license + ' License';
const banner = '//! CLABE Validator v' + [pkg.version, home, license].join(' ~ ') + '\n';
const htmlHintConfig = { 'attr-value-double-quotes': false };
const jsHintConfig = { strict: 'implied', undef: true, unused: true, browser: true, node: true };
const jsHintConfig = { strict: 'implied', undef: true, unused: true, browser: true, node: true };
const analyze = {
html: function() {
// Tasks
const task = {
analyzeHtml: function() {
return gulp.src('*.html')
.pipe(w3cJs())
.pipe(w3cJs.reporter())
.pipe(w3cHtmlValidator())
.pipe(w3cHtmlValidator.reporter())
.pipe(htmlHint(htmlHintConfig))
.pipe(htmlHint.reporter());
},
js: function() {
analyzeJs: function() {
return gulp.src('clabe.js')
.pipe(jshint(jsHintConfig))
.pipe(jshint.reporter());
},
setVersion: function() {
const semVerPattern = /\d+[.]\d+[.]\d+/g;
return gulp.src('clabe.js')
.pipe(replace(semVerPattern, pkg.version))
.pipe(gulp.dest('.'));
},
minify: function() {
return gulp.src('clabe.js')
.pipe(rename('clabe.min.js'))
.pipe(uglify())
.pipe(header(banner))
.pipe(size({ showFiles: true }))
.pipe(gulp.dest('.'));
}
};
function setVersion() {
return gulp.src('clabe.js')
.pipe(replace(/v\d+[.]\d+[.]\d+/, 'v' + pkg.version)) //example: "v0.0.0"
.pipe(gulp.dest('.'));
}
function minify() {
return gulp.src('clabe.js')
.pipe(rename('clabe.min.js'))
.pipe(uglify())
.pipe(header(banner))
.pipe(size({ showFiles: true }))
.pipe(gulp.dest('.'));
}
gulp.task('lint-html', gulp.series(analyze.html));
gulp.task('lint-js', gulp.series(analyze.js));
gulp.task('lint', gulp.series(['lint-html', 'lint-js']));
gulp.task('version', gulp.series(setVersion));
gulp.task('build', gulp.series(['version'], minify));
// Gulp
gulp.task('lint-html', task.analyzeHtml);
gulp.task('lint-js', task.analyzeJs);
gulp.task('version', task.setVersion);
gulp.task('minify', task.minify);
{
"name": "clabe-validator",
"version": "1.0.3",
"version": "1.0.4",
"description": "JavaScript library to analyze or create a CLABE number for a Mexican bank account",
"license": "MIT",
"main": "clabe.js",
"repository": "center-key/clabe-validator",
"repository": "github:center-key/clabe-validator",
"homepage": "https://github.com/center-key/clabe-validator",

@@ -32,3 +32,3 @@ "bugs": "https://github.com/center-key/clabe-validator/issues",

"scripts": {
"pretest": "jshint gulpfile.js spec.js && gulp lint && gulp build",
"pretest": "jshint gulpfile.js spec.js && gulp lint-html && gulp lint-js && gulp version && gulp minify",
"test": "mocha spec.js"

@@ -35,0 +35,0 @@ },

# CLABE Validator
*JavaScript library to analyze or create a CLABE number for a Mexican bank account*
<img src=https://centerkey.com/graphics/center-key-logo.svg align=right width=200 alt=logo>
_JavaScript library to analyze or create a CLABE number for a Mexican bank account_
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/center-key/clabe-validator/blob/master/LICENSE.txt)

@@ -11,3 +13,3 @@ [![npm](https://img.shields.io/npm/v/clabe-validator.svg)](https://www.npmjs.com/package/clabe-validator)

standard from the Mexican Bank Association (Asociación de Bancos de México &ndash; ABM) for
uniform numbering of bank accounts.
uniform numbering of bank accounts. See: https://en.wikipedia.org/wiki/CLABE

@@ -21,6 +23,6 @@ ### A) Online form

```html
<script src=clabe.js></script>
<script src=clabe.min.js></script>
```
From the jsdelivr.com CDN:
From the [jsdelivr.com CDN](https://www.jsdelivr.com/package/npm/clabe-validator):
```html

@@ -43,4 +45,4 @@ <script src=https://cdn.jsdelivr.net/npm/clabe-validator@1.0/clabe.min.js></script>

```javascript
var clabeNum = '002010077777777771';
var clabeCheck = clabe.validate(clabeNum);
const clabeNum = '002010077777777771';
const clabeCheck = clabe.validate(clabeNum);
console.log(clabeCheck.error ? '¡Muy mal!' : '¡Que bueno!');

@@ -79,3 +81,3 @@ ```

```javascript
var clabeNum = clabe.calculate(2, 10, 7777777777);
const clabeNum = clabe.calculate(2, 10, 7777777777);
console.log(clabeNum === '002010077777777771');

@@ -93,2 +95,2 @@ ```

and the documentation is published under the
[CC BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0) license.
[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0) license.

@@ -8,6 +8,19 @@ // CLABE Validator

const assert = require('assert');
// Imports
const assert = require('assert').strict;
const clabe = require('./clabe.js');
////////////////////////////////////////////////////////////////////////////////////////////////////
describe('Library version number', () => {
it('follows semantic version formatting', () => {
const semVerPattern = /\d+[.]\d+[.]\d+/;
const actual = { valid: semVerPattern.test(clabe.version) };
const expected = { valid: true };
assert.deepEqual(actual, expected);
});
});
////////////////////////////////////////////////////////////////////////////////////////////////////
describe('List of CLABE banks', () => {

@@ -22,3 +35,5 @@

function evalData(data) {
assert.equal(clabe.bank[parseInt(data.input)], data.expected);
const actual = { code: data.input, name: clabe.banksMap[parseInt(data.input)] };
const expected = { code: data.input, name: data.expected };
assert.deepEqual(actual, expected);
}

@@ -29,3 +44,5 @@ dataSet.forEach(evalData);

it('has a default "N/A" bank for code 999', () => {
assert.equal(clabe.bank[999], 'N/A');
const actual = { code: 999, name: clabe.banksMap[999] };
const expected = { code: 999, name: 'N/A' };
assert.deepEqual(actual, expected);
});

@@ -37,3 +54,3 @@

describe('List of CLABE cities', () => {
let cityNamesMap = {};
const cityNamesMap = {}; //{ Aguascalientes: 10, Calvillo: 12, ... }
function addCity(city) { cityNamesMap[city[1]] = city[0]; }

@@ -43,5 +60,8 @@ clabe.cities.forEach(addCity);

it('is in numerical order', () => {
function checkOrder(city, i) {
var priorCode = i > 0 ? clabe.cities[i - 1][0] : 0;
assert.ok(city[0] >= priorCode, 'After #' + priorCode + ', out of order city: #' + city);
function checkOrder(city, i) { //example city: [10, 'Aguascalientes']
const priorCode = i > 0 ? clabe.cities[i - 1][0] : 0;
const ordered = city[0] >= priorCode;
const actual = { city: city[1], code: city[0], prior: priorCode, ordered: ordered };
const expected = { city: city[1], code: city[0], prior: priorCode, ordered: true };
assert.deepEqual(actual, expected);
}

@@ -59,3 +79,5 @@ clabe.cities.forEach(checkOrder);

function evalData(data) {
assert.equal(cityNamesMap[data.input], parseInt(data.expected));
const actual = { city: data.input, code: cityNamesMap[data.input] };
const expected = { city: data.input, code: parseInt(data.expected) };
assert.deepEqual(actual, expected);
}

@@ -67,4 +89,7 @@ dataSet.forEach(evalData);

function checkForDuplicate(city) {
if (cityNamesMap[city[1]] !== city[0] && city[1] !== 'N/A')
assert.equal(city, 'Not unique -- see: ' + cityNamesMap[city[1]]);
const code = cityNamesMap[city[1]];
const unique = city[0] === code || city[1] === 'N/A';
const actual = { city: city[1], code1: city[0], code2: code, unique: unique };
const expected = { city: city[1], code1: city[0], code2: code, unique: true };
assert.deepEqual(actual, expected);
}

@@ -86,3 +111,6 @@ clabe.cities.forEach(checkForDuplicate);

function evalData(data) {
assert.equal(clabe.validate(data.input).message, data.expected);
const result = clabe.validate(data.input);
const actual = { clabe: data.input, error: result.error, message: result.message };
const expected = { clabe: data.input, error: true, message: data.expected };
assert.deepEqual(actual, expected);
}

@@ -100,3 +128,7 @@ dataSet.forEach(evalData);

function evalData(data) {
assert.equal(clabe.validate(data).message.substr(0, 6), 'Valid:');
const result = clabe.validate(data);
const valid = /^Valid:/.test(result.message);
const actual = { clabe: data, error: result.error, valid: valid };
const expected = { clabe: data, error: false, valid: true };
assert.deepEqual(actual, expected);
}

@@ -120,3 +152,5 @@ dataSet.forEach(evalData);

const clabeNum = clabe.calculate(data.input.bank, data.input.city, data.input.acct);
assert.equal(clabeNum, data.expected);
const actual = { details: data.input, clabe: clabeNum };
const expected = { details: data.input, clabe: data.expected };
assert.deepEqual(actual, expected);
}

@@ -123,0 +157,0 @@ dataSet.forEach(evalData);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc