Add more postcode countries: India, Germany, Australia

Open
#41 4 comments 0 reactions 2 assignees View on GitHub

Maintainers usually reply within 1 day

@mohsin-usmani is already working on this.

Since Dec 4, 2026.

Assessment

This issue has not been assessed yet.

Description

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
Dominant language
JavaScript
Stars
0
Forks
7
Avg merge
1h 17m
Merged PRs (30d)
6

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aniru-dh21/snap-validate

All issues in aniru-dh21/snap-validate

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.