Unknown country or format codes silently fall back to defaults

Open
#37 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@sumitkhond111-del is already working on this.

Since Dec 4, 2026.

  • #49 by @sumitkhond111-del — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Domain
backend

Research direction

Start by reading the zipCode and phone validator implementations, the existing phone fallback test, and the README and type definitions mentioned in the issue. A linked open pull request (#49) is already working on this issue. The thread asks maintainers to decide among three behavior options, so the expected change and what counts as done are not yet settled.

Written by the indexing model from the issue text.

Description

discussion enhancement

zipCode falls back to the US pattern for an unknown country, and phone falls back to simple for an unknown format. So a typo or an unsupported country fails quietly:

validators.zipCode('2000', 'au').validate();
// { isValid: false, errors: ['Invalid zip code format'] }
// checked against the US pattern, not rejected as "unsupported country"

Options:

  1. Throw a clear error when the validator is created, e.g. Unsupported country code 'au'. Clearest, but a breaking change for anyone relying on the fallback (an existing test expects the phone fallback).
  2. Keep the fallback and print a one-time console.warn.
  3. Keep the behaviour and document it in the README and type definitions.

Thoughts welcome before anyone starts on this.

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.