个人 GitHub 账号下公开仓库的所有者可以登录并验证所有权,自行管理介绍,无需管理员批准。
登录并生成验证文件,在 30 分钟内将其提交到此仓库的默认分支。其他分支或分叉仓库中的文件无效。然后在下方检查文件,即可无需管理员批准直接管理项目。请保留文件以维持管理权限。
如需登录,将前往登录页面。登录后请回到此处,再次点击所选的验证按钮。
在项目文件夹中运行 /nomorevibe verify,即可验证所有权并自行管理介绍。
一分钟完成验证Validate and decode Romanian CNP, CUI/CIF, IBAN and postal codes. Explains every error and shows how the check digit is computed. Zero dependencies, runs in the browser
翻译准备中
取自仓库 README
正在加载完整 README。
查看完整 README ↗Validate and decode Romanian identifiers (CNP, CUI/CIF, IBAN and postal codes) with error messages you can show directly to users. Zero dependencies, fully typed, runs in Node and in the browser.
npm install github:Robert-GeorgeDev/ValidRO
The package is not on the npm registry yet; this installs it straight from GitHub and builds it.
70, which the civil-status system (SIIEASC) now assigns to newly generated CNPs. Many older validators reject these valid codes.Cifra de control este greșită (așteptat 7).import { validateCnp, validateCui, validateIbanRo } from "validro";
validateCnp("3000101221147");
// {
// valid: true,
// error: null,
// data: { cnp: "3000101221147", sex: "M", birthDate: "1800-01-01",
// countyCode: "22", county: "Iași", foreigner: false }
// }
validateCnp("3000101221148");
// { valid: false, error: "Cifra de control este greșită (așteptat 7)", data: null }
validateCui("RO12345674");
// { valid: true, error: null, data: { cui: "12345674", hasRoPrefix: true } }
validateIbanRo("ro49 aaaa 1b31 0075 9384 0000");
// { valid: true, error: null,
// data: { iban: "RO49AAAA1B31007593840000", formatted: "RO49 AAAA 1B31 0075 9384 0000",
// bankCode: "AAAA", treasury: false } }
Every validate* function returns the same shape, so you can handle all of them the same way:
type ValidationResult<T> =
| { valid: true; error: null; data: T }
| { valid: false; error: string; data: null };
Only need true or false? Use isValidCnp, isValidCui, isValidIbanRo and isValidPostalCode.
| Function | Returns |
|---|---|
validateCnp(cnp, now?) | ValidationResult<CnpInfo>; now sets the date used to reject future birth dates |
validateCui(cui) | ValidationResult<CuiInfo> |
validateIbanRo(iban) | ValidationResult<IbanInfo> |
validatePostalCode(postalCode) | ValidationResult<PostalCodeInfo>; exactly 6 digits |
isValidCnp, isValidCui, isValidIbanRo, isValidPostalCode | boolean |
cnpControlDigit(first12) | the CNP control digit |
cuiControlDigit(body) | the CUI control digit |
ibanChecksumOk(iban) | mod-97 check, works for any country |
CNP_COUNTIES | county codes and names |
| Identifier | Checks |
|---|---|
| CNP | 13 digits, sex and century digit, real calendar date including leap years, not in the future, county code (01–52, 70), sequence not 000, control digit (key 279146358279) |
| CUI / CIF | optional RO prefix, 2–10 digits, no leading zero, control digit (key 753217532) |
| IBAN (RO) | 24 characters: RO, 2 check digits, 4-letter bank code, 16 alphanumerics, ISO 13616 mod-97 |
| Postal code | exactly 6 digits |
Spaces, dots and dashes in the input are ignored.
A valid code is well-formed; it does not prove the code exists. A valid CNP may belong to no one, and a valid CUI may be a closed company. To confirm a company is active, query the public ANAF services.
For residents and foreigners (CNP starting with 7, 8 or 9) the century is not encoded, so ValidRO picks the most recent century that does not put the birth date in the future.
ValidRO never makes network requests. The demo page runs the same code in your browser.
All examples in this repository are fictitious: sample CNPs use birth dates in the 1800s, and the IBAN is the official example from the ISO 13616 registry. Please never paste real personal data into issues or tests.
+40Ideas and bugs are welcome in issues. See CONTRIBUTING.md to get started.