{"id":22897267,"url":"https://github.com/center-key/clabe-validator","last_synced_at":"2025-05-16T14:06:44.964Z","repository":{"id":56537780,"uuid":"78330554","full_name":"center-key/clabe-validator","owner":"center-key","description":"🇲🇽 Analyze or create a CLABE number for a Mexican bank account (with TypeScript declarations)","archived":false,"fork":false,"pushed_at":"2025-04-09T09:30:45.000Z","size":1004,"stargazers_count":70,"open_issues_count":1,"forks_count":33,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-11T21:41:14.198Z","etag":null,"topics":["bank","bank-account","clabe","clabe-number","clabe-validator","financial","javascript","typescript"],"latest_commit_sha":null,"homepage":"https://clabe-validator.js.org","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/center-key.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-01-08T08:25:19.000Z","updated_at":"2025-05-06T23:31:56.000Z","dependencies_parsed_at":"2023-11-10T12:29:23.764Z","dependency_job_id":"452a0ad2-9870-4df1-aaf9-d2a4820be407","html_url":"https://github.com/center-key/clabe-validator","commit_stats":{"total_commits":426,"total_committers":18,"mean_commits":"23.666666666666668","dds":0.07276995305164324,"last_synced_commit":"e511e99706c51460fbfc46601afbcf0571a9ffa3"},"previous_names":[],"tags_count":69,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/center-key%2Fclabe-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/center-key%2Fclabe-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/center-key%2Fclabe-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/center-key%2Fclabe-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/center-key","download_url":"https://codeload.github.com/center-key/clabe-validator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254544146,"owners_count":22088807,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bank","bank-account","clabe","clabe-number","clabe-validator","financial","javascript","typescript"],"created_at":"2024-12-14T00:16:23.768Z","updated_at":"2025-05-16T14:06:44.941Z","avatar_url":"https://github.com/center-key.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CLABE Validator\n\u003cimg src=https://centerkey.com/graphics/center-key-logo.svg align=right width=200 alt=logo\u003e\n\n_JavaScript library to analyze or create a CLABE number for a Mexican bank account_\n\n[![License:MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/center-key/clabe-validator/blob/main/LICENSE.txt)\n[![npm](https://img.shields.io/npm/v/clabe-validator.svg)](https://www.npmjs.com/package/clabe-validator)\n[![Hits](https://data.jsdelivr.com/v1/package/npm/clabe-validator/badge?style=rounded)](https://www.jsdelivr.com/package/npm/clabe-validator)\n[![Build](https://github.com/center-key/clabe-validator/actions/workflows/run-spec-on-push.yaml/badge.svg)](https://github.com/center-key/clabe-validator/actions/workflows/run-spec-on-push.yaml)\n\nCLABE (Clave Bancaria Estandarizada \u0026mdash; Spanish for \"standardized banking code\") is a banking\nstandard from the Mexican Bank Association (Asociación de Bancos de México \u0026mdash; ABM) for\nuniform numbering of bank accounts.\u0026nbsp; CLABE numbers are 18 digits long.\u0026nbsp;\nSee: https://en.wikipedia.org/wiki/CLABE\n\n## A) Online Form\nTry it out:\u003cbr\u003e\n[https://centerkey.com/clabe](https://centerkey.com/clabe/)\n\n## B) Setup\n### Web browser\nInclude in a web page:\n```html\n\u003cscript src=clabe.min.js\u003e\u003c/script\u003e\n```\nor from the [jsdelivr.com CDN](https://www.jsdelivr.com/package/npm/clabe-validator):\n```html\n\u003cscript src=https://cdn.jsdelivr.net/npm/clabe-validator@3.0/dist/clabe.min.js\u003e\u003c/script\u003e\n```\n### Node.js server\nInstall package for node:\n```shell\n$ npm install clabe-validator\n```\nImport package:\n```javascript\nimport { clabe } from 'clabe-validator';\n```\n\n## C) Validator Usage\nPass the CLABE number as an 18-character string into `clabe.validate(clabeNum)`.\n\n### 1. Example JavaScript code\n```javascript\nconst clabeNum =   '002010077777777771';\nconst clabeCheck = clabe.validate(clabeNum);\nconsole.log(clabeCheck.ok ? '¡Que bueno!' : '¡Muy mal!');\nconsole.log('Your bank: ' + clabeCheck.bank);\n```\n\n### 2. Example JSON result for a valid CLABE number\n```javascript\n{\n   ok:       true,\n   formatOk: true,\n   error:    null,\n   message:  'Valid',\n   clabe:    '002010077777777771',\n   tag:      'BANAMEX',\n   bank:     'Banco Nacional de México',\n   city:     'Aguascalientes MX-AGU',\n   multiple: false,\n   total:    1,\n   account:  '07777777777',\n   code:     { bank: '002', city: '010' },\n   checksum: 1,\n}\n```\n\n### 3. Example JSON result for an invalid CLABE number\n```javascript\n{\n   ok:       false,\n   formatOk: true,\n   error:    'invalid-city',\n   message:  'Invalid city code: 000',\n}\n```\nThe `formatOk` field indicates if the CLABE's length and checksum are both valid (even if the bank\ncode or city code are unknown).\n\n### 4. Possible errors\n| Error code           | Error message                                   | Format Ok |\n| -------------------- | ----------------------------------------------- | ----------|\n| `invalid-length`     | Must be exactly 18 digits long                  | `false`   |\n| `invalid-characters` | Must be only numeric digits (no letters)        | `false`   |\n| `invalid-checksum`   | Invalid checksum, last digit should be: [DIGIT] | `false`   |\n| `invalid-bank`       | Invalid bank code: [CODE]                       | `true`    |\n| `invalid-city`       | Invalid city code: [CODE]                       | `true`    |\n\n## D) Calculator Usage\nPass the bank code, city code, and account number into\n`clabe.calculate(bankCode, cityCode, accountNumber)`\nand get the 18-character CLABE number back.\n\n```javascript\nconst clabeNum = clabe.calculate(2, 10, 7777777777);\nconsole.log(clabeNum === '002010077777777771');  //true\n```\n\n## E) TypeScript Declarations\nSee the TypeScript declarations at the top of the [clabe.ts](src/clabe.ts) file.\n\nThe `clabe.validate(clabeNum: string)` function returns a `ClabeCheck` object:\n```typescript\ntype ClabeCheck = {\n   ok:       boolean,        //todo está bien\n   formatOk: boolean,        //valid length and checksum\n   error:    string | null,  //failure code, example: 'invalid-city'\n   message:  string,         //displayable status information\n   clabe:    string | null,  //full 18-digit number\n   tag:      string | null,  //bank short name, example: 'BANAMEX'\n   bank:     string | null,  //bank long name, example: 'Banco Nacional'\n   city:     string | null,  //branch or plaza name\n   multiple: boolean,        //more than one city share the same code\n   total:    number,         //number of cities\n   account:  string,         //11-digit zero-padded bank account number\n   code:     { bank: string, city: string },  //3-digit codes\n   checksum: number | null,  //control digit (0 to 9)\n   };\n```\n\nExample TypeScript usage with explicit types:\n```typescript\nimport { clabe, ClabeCheck } from 'clabe-validator';\n\nconst clabeNum:   string =     '002010077777777771';\nconst clabeCheck: ClabeCheck = clabe.validate(clabeNum);  //{ ok: true, error: null, ... }\nconst bankCode:   string =     clabeCheck.code.bank;      //'002'\n```\n\n## F) Contributor Notes\nTo be a contributor, **fork** the project and run the commands `npm install` and `npm test` on your local clone.\u0026nbsp;\nMake your edits and rerun the tests.\n\nPull requests welcome.\u0026nbsp;\nSince the pacakge version number is updated during the release process, **leave the version number unchanged.**\n\n## G) Genesis\nThe origin of this project goes back to when I needed to send money to Guanajuato, Mexico to pay\nnurses who were providing medical care of a relative.\u0026nbsp;\nI was initially unable to transfer funds because the money transfer service reported that the CLABE\nnumber I supplied was invalid.\u0026nbsp;\nThrough a little sleuthing and a lot of luck, I discovered that a financial services company had\naccidentally omitted the very last modulo operation in their CLABE checksum calculation.\u0026nbsp;\nThe result was that valid Mexican bank account numbers with certain combinations of digits were\nerroneously rejected.\n\nThis project was created to fix the checksum bug.\u0026nbsp;\nIt is an open source community project and is not supported by any company.\n\n## H) Build Environment\nCheck out the `runScriptsConfig` section in [package.json](package.json) for an\ninteresting approach to organizing build tasks.\n\n**CLI Build Tools for package.json**\n   - 🎋 [add-dist-header](https://github.com/center-key/add-dist-header):\u0026nbsp; _Prepend a one-line banner comment (with license notice) to distribution files_\n   - 📄 [copy-file-util](https://github.com/center-key/copy-file-util):\u0026nbsp; _Copy or rename a file with optional package version number_\n   - 📂 [copy-folder-util](https://github.com/center-key/copy-folder-util):\u0026nbsp; _Recursively copy files from one folder to another folder_\n   - 🪺 [recursive-exec](https://github.com/center-key/recursive-exec):\u0026nbsp; _Run a command on each file in a folder and its subfolders_\n   - 🔍 [replacer-util](https://github.com/center-key/replacer-util):\u0026nbsp; _Find and replace strings or template outputs in text files_\n   - 🔢 [rev-web-assets](https://github.com/center-key/rev-web-assets):\u0026nbsp; _Revision web asset filenames with cache busting content hash fingerprints_\n   - 🚆 [run-scripts-util](https://github.com/center-key/run-scripts-util):\u0026nbsp; _Organize npm package.json scripts into groups of easy to manage commands_\n   - 🚦 [w3c-html-validator](https://github.com/center-key/w3c-html-validator):\u0026nbsp; _Check the markup validity of HTML files using the W3C validator_\n\n\u003cbr\u003e\n\n---\nFeel free to submit questions at:\u003cbr\u003e\n[github.com/center-key/clabe-validator/issues](https://github.com/center-key/clabe-validator/issues)\n\nCLABE Validator code is open source under the [MIT License](LICENSE.txt),\nand the documentation is published under the\n[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcenter-key%2Fclabe-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcenter-key%2Fclabe-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcenter-key%2Fclabe-validator/lists"}