{"slug": "validating-id-numbers-from-7-spanish-speaking-countries-with-check-digits", "title": "Validating ID numbers from 7 Spanish-speaking countries with check digits", "summary": "A developer at Zaisor Technology built VeloPrompt, an open-source (MIT) browser extension that detects personal data in text before it is pasted into an AI chat and replaces it with labels such as [CEDULA_1] or [IBAN_1], restoring the real values only on the user's screen. The core engine (veloprompt-core) is dependency-free TypeScript that validates check digits for identifiers from seven Spanish-speaking countries — Ecuadorian cédula, Spanish DNI/NIF, Chilean RUT, Mexican CURP/RFC/CLABE, Colombian NIT, Peruvian RUC and Argentine CUIT/CUIL — plus IBANs and Luhn-checked cards, and runs detect() over 50,000 characters in about 3 ms. Numbers without a checksum, such as Peruvian DNI or Colombian cédula, are matched only when a nearby context word is present, and the extension makes no network requests, keeping the label-to-value map in the tab's memory.", "body_md": "People paste contracts, client lists and bank emails into ChatGPT every day. We built [VeloPrompt](https://github.com/zaisor-technology/veloprompt?utm_source=devto&utm_medium=post&utm_campaign=lanzamiento-veloprompt), an open-source (MIT) browser extension that spots personal data before it reaches an AI chat and swaps it for labels like [CEDULA_1] or [IBAN_1]. The AI works with the labels; the real values come back only on your screen.\n\nMost tools in this space are built around US and English formats. Our users are in Spain and Latin America, where the sensitive numbers are a cédula, a RUC, a DNI, a CURP or a RUT. This post is about the part that took the most care: detecting those numbers without flagging every order ID and invoice amount.\n\nA 10-digit number can be an Ecuadorian cédula, a phone number, an order ID or a timestamp. If you match by shape alone, the extension warns on everything and people turn it off. So every rule validates the number's own check digit before it counts.\n\n**Ecuador, cédula (modulo 10).** The first two digits are the province (01-24 or 30). Multiply the first nine digits by 2,1,2,1,..., subtract 9 from any product above 9, sum them, and the check digit is (10 - sum mod 10) mod 10.\n\n**Spain, DNI/NIF (letter).** The letter is \"TRWAGMYFPDXBNJZSQVHLCKE\"[number mod 23]. For a NIE, replace the leading X, Y or Z with 0, 1 or 2 and apply the same rule.\n\n**Chile, RUT (modulo 11).** Multiply the digits from right to left by 2,3,4,5,6,7 (and repeat), take 11 - (sum mod 11); 11 means 0 and 10 means K. It has to accept both 12.345.678-5 and 12345678-5.\n\nThe same idea covers Mexico (CURP, RFC, CLABE), Colombia (NIT), Peru (RUC), Argentina (CUIT/CUIL, CBU), Spanish CIF and IBANs (mod 97), plus cards with Luhn.\n\nA Peruvian DNI or a Colombian cédula has no checksum. For those, the number only counts if a context word is nearby (\"DNI\", \"C.C.\", \"cédula\"). And a valid-looking number is still ignored if it follows words like \"pedido\", \"factura\" or \"seguimiento\", or looks like an amount.\n\nWhen two rules match the same number (a Peruvian RUC and an Argentine CUIT that both start with 20 share the same arithmetic), the one with context wins. Either way the value gets masked; only the label can differ.\n\nThe test suite never uses real documents. A separate generator builds valid numbers with its own implementation of each algorithm, so the tests do not validate the code against itself. Each rule is tested with valid numbers, numbers with a wrong check digit (which must not match) and look-alikes such as order IDs and dates. detect() runs on 50,000 characters in about 3 ms.\n\nThe engine (veloprompt-core) is plain TypeScript with no runtime dependencies. The extension makes no network requests, and the label-to-value map lives only in the tab's memory.\n\nEach country is one rules file with its tests, so adding a country is a small, self-contained pull request. If you work with IDs from a country we do not cover yet, we would love the contribution: [github.com/zaisor-technology/veloprompt](https://github.com/zaisor-technology/veloprompt?utm_source=devto&utm_medium=post&utm_campaign=lanzamiento-veloprompt)\n\nWhat do you do today to keep personal data out of AI chats?", "url": "https://wpnews.pro/news/validating-id-numbers-from-7-spanish-speaking-countries-with-check-digits", "canonical_source": "https://dev.to/jdevleon/validating-id-numbers-from-7-spanish-speaking-countries-with-check-digits-bbh", "published_at": "2026-10-27 15:32:54+00:00", "updated_at": "2026-10-27 15:42:06.749134+00:00", "lang": "en", "topics": ["ai-tools", "ai-safety", "ai-products", "developer-tools", "artificial-intelligence"], "entities": ["VeloPrompt", "Zaisor Technology", "GitHub", "ChatGPT"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/validating-id-numbers-from-7-spanish-speaking-countries-with-check-digits", "markdown": "https://wpnews.pro/news/validating-id-numbers-from-7-spanish-speaking-countries-with-check-digits.md", "text": "https://wpnews.pro/news/validating-id-numbers-from-7-spanish-speaking-countries-with-check-digits.txt", "jsonld": "https://wpnews.pro/news/validating-id-numbers-from-7-spanish-speaking-countries-with-check-digits.jsonld"}}