Add more postcode countries: India, Germany, Australia

Aperta
#41 4 commenti 0 reazioni 2 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@mohsin-usmani ci sta già lavorando.

Dal 4/12/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

enhancement good first issue

zipCode() supports us, ca and uk. Adding a country is a contained change that touches every layer of the library, so it's a good way to learn the codebase.

Status

  • in: India, taken by @Rewaskc02-lang
  • de: Germany, taken by @mohsin-usmani
  • au: Australia, open

One country per pull request is fine. Comment saying which one you're taking.

Suggested formats

Please double-check each against an official source and link it in your pull request.

  • in: India PIN code, 6 digits, not starting with 0 (/^[1-9]\d{5}$/)
  • de: Germany, 5 digits. Leading zeros are valid (e.g. 01067 Dresden)
  • au: Australia, 4 digits. Leading zeros are valid, since Northern Territory codes start with 0 (e.g. 0800 Darwin), so don't use [1-9]

Use lowercase codes (in, de, au) to match the existing us, ca and uk.

Files to touch

  • src/validators/zipCode.js: add the regex
  • types/index.d.ts: add the code to CountryCode
  • test-types.ts: add a line using the new code
  • tests/validators.test.js: valid and invalid examples
  • site/main.js: add it to the playground's Country dropdown and to postcodeSamples
  • README: "Zip Code Validation"

Heads-up on tests: zipCode() falls back to the US regex for unknown country codes (zipRegex[country] || zipRegex.us). Include at least one case where the new country and the US disagree, so the test fails without your change (e.g. '12345-6789' invalid for de, '2000' valid for au).

Done when

  • All of the above, and npm test, npm run type-check and npm run size pass
Lingua principale
JavaScript
Stelle
0
Fork
7
Merge medio
1h 17m
PR unite (30g)
6

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di aniru-dh21/snap-validate

Tutte le issue di aniru-dh21/snap-validate

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.