diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24ba33b..046d9d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,9 @@ on: branches: [main] pull_request: +permissions: + contents: read + jobs: test: runs-on: ubuntu-latest @@ -20,3 +23,10 @@ jobs: - run: npm run typecheck - run: npm test - run: npm run build + - name: Check the published files + run: npm pack --dry-run + - name: Smoke test the ESM and CommonJS builds + run: | + node --input-type=module -e "import { validateCnp } from './dist/index.js'; if (!validateCnp('3000101221147').valid) process.exit(1); console.log('ESM ok')" + node -e "const { validateCnp } = require('./dist/index.cjs'); if (!validateCnp('3000101221147').valid) process.exit(1); console.log('CJS ok')" + test -f dist/index.d.ts && test -f dist/index.d.cts && echo "type declarations ok" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7d3f6d0..ff7441f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -11,6 +11,8 @@ permissions: jobs: publish: runs-on: ubuntu-latest + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} steps: - uses: actions/checkout@v7 - uses: actions/setup-node@v7 @@ -18,6 +20,11 @@ jobs: node-version: 22 registry-url: https://registry.npmjs.org - run: npm install - - run: npm publish --provenance --access public - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - run: npm run typecheck && npm test + # Until an NPM_TOKEN secret is added, tags only create a GitHub release. + - name: Skip npm publish (no NPM_TOKEN secret yet) + if: env.NODE_AUTH_TOKEN == '' + run: echo "::notice::NPM_TOKEN is not set, so this release was not published to npm." + - name: Publish + if: env.NODE_AUTH_TOKEN != '' + run: npm publish --provenance --access public diff --git a/CHANGELOG.md b/CHANGELOG.md index f9202c5..c3f050d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,6 @@ All notable changes to this project are documented here. The format follows [Kee ## [Unreleased] -### Added - -- `validatePostalCode` / `isValidPostalCode` for six-digit Romanian postal code format validation - ## [0.1.0] - 2026-10-27 ### Added @@ -16,4 +12,8 @@ All notable changes to this project are documented here. The format follows [Kee - `validateCui` / `isValidCui`, with or without the `RO` prefix - `validateIbanRo` / `isValidIbanRo`, with formatting and bank code - Control-digit helpers: `cnpControlDigit`, `cuiControlDigit`, `ibanChecksumOk` -- Demo page that splits a code into its parts and explains each one +- `validatePostalCode` / `isValidPostalCode` for six-digit Romanian postal codes (thanks @jay23606, #12) +- Demo page that splits a code into its parts, explains each one and shows how the check digit is computed + +[Unreleased]: https://github.com/Robert-GeorgeDev/ValidRO/compare/v0.1.0...HEAD +[0.1.0]: https://github.com/Robert-GeorgeDev/ValidRO/releases/tag/v0.1.0 diff --git a/README.md b/README.md index 0265a32..a82e679 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,9 @@
diff --git a/docs/index.html b/docs/index.html index 719d1fc..9916f25 100644 --- a/docs/index.html +++ b/docs/index.html @@ -9,6 +9,7 @@ + @@ -77,6 +78,7 @@ .kinds button:hover { color: var(--ink); } .kinds button[aria-selected="true"] { background: var(--stamp); color: var(--sheet); } .kinds button:focus-visible { outline-offset: -3px; } + .narrow-only { display: none; } .field-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; } .field-head label { font-size: 0.95rem; color: var(--ink-2); } @@ -185,6 +187,9 @@ .tool { padding: 18px 14px; } .kinds { display: flex; } .kinds button { flex: 1; padding: 10px 0; } + .kinds button { white-space: nowrap; } + .wide-only { display: none; } + .narrow-only { display: inline; } input#code { font-size: 1.25rem; padding-right: 48px; } .result { grid-template-columns: 1fr; } .stamp { width: 72px; height: 72px; justify-self: end; margin-top: -8px; } @@ -219,13 +224,14 @@
Verifică un CNP, un CUI sau un IBAN, vezi ce înseamnă fiecare cifră și cum se calculează cifra de control.
+Verifică un CNP, un CUI, un IBAN sau un cod poștal, vezi ce înseamnă fiecare cifră și cum se calculează cifra de control.
Un cod valid e corect ca formă; asta nu înseamnă că aparține cuiva. Exemplele de pe pagină sunt fictive.
@@ -292,7 +299,7 @@