Skip to content

fix(isLatLong): reject extra coordinate components - #2880

Open
Jerry-val wants to merge 2 commits into
validatorjs:masterfrom
Jerry-val:fix/latlong-coordinate-pair
Open

fix(isLatLong): reject extra coordinate components#2880
Jerry-val wants to merge 2 commits into
validatorjs:masterfrom
Jerry-val:fix/latlong-coordinate-pair

Conversation

@Jerry-val

Copy link
Copy Markdown

isLatLong splits the input on commas but validates only the first two components, so isLatLong('0,0,garbage') and a valid DMS pair followed by ,garbage return true.

Require exactly two components before validating them. This rejects trailing commas and additional numeric or text fields in both decimal and DMS modes, matching the documented lat,long / lat, long format. Existing coordinate ranges, parentheses and formatting checks remain unchanged.

Reference: documented isLatLong format. I checked related open and closed PRs; #1074 handles parentheses and #1340 adds DMS support, but neither checks for extra components. The open test reorganization in #2698 does not fix this behavior.

Validation on Node.js 24.19.0:

  • Added two regression tests covering 10 malformed inputs; both tests fail against unchanged master.
  • npm test passes: 325 tests, including build and lint.
  • 88 additional assertions pass across source, Node, browser and minified browser builds.
  • git diff --check passes.

This change was prepared and independently reviewed with Codex; the checks above were run locally.

Checklist

  • PR contains only related changes
  • README reviewed; existing documented pair format already describes the intended behavior
  • Regression tests added
  • References provided

@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a79ff98) to head (fd05da7).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2880   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2599      2598    -1     
  Branches       658       658           
=========================================
- Hits          2599      2598    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nrps9909 nrps9909 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified exact head fd05da79e532eb787809a0c71071b2fda8364906 against base a79ff980ab14257e795332989e497bdff3218e87.

Both new tests fail on the unchanged base for the reported reason: decimal and DMS pairs with a trailing comma are accepted. The head passes the complete npm test workflow: build, lint and 325 tests on Node 24.15.0. All 13 currently reported upstream checks pass.

An independent 2,450-case corpus was run against each of source, Node, browser and minified-browser builds. It covers decimal range boundaries, signs, spaces, parentheses, extra empty/numeric/text components, canonical DMS pairs, missing commas and non-string argument errors. Each base form has 1,310 false accepts; all four head forms have zero mismatches in this corpus (9,800 head observations total). The reference expectations are constructed from the selected numeric ranges and known valid DMS pairs, not copied from the implementation regexes.

The exact-two-component guard matches the documented pair format and leaves the existing range/format expressions unchanged. Approval is scoped to rejecting extra components; this is not a claim of exhaustive DMS or geographic-format conformance. Both review worktrees are restored clean. AI-assisted review with independently executed validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants