Validating ID numbers from 7 Spanish-speaking countries with check digits 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. 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. Most 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. A 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. 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. 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. 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. The 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. A 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. When 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. The 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. The 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. Each 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 What do you do today to keep personal data out of AI chats?