個人 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.