Visitar URL original
fix(isLatLong): bound DMS longitude degrees by FanWu-ai · Pull Request #2922 · validatorjs/validator.js · GitHub
Skip to content

fix(isLatLong): bound DMS longitude degrees - #2922

Open
FanWu-ai wants to merge 1 commit into
validatorjs:masterfrom
FanWu-ai:fix/dms-longitude-degrees
Open

FanWu-ai wants to merge 1 commit into
validatorjs:masterfrom
FanWu-ai:fix/dms-longitude-degrees

Conversation

@FanWu-ai

@FanWu-ai FanWu-ai commented Oct 8, 2026

Copy link
Copy Markdown

isLatLong(str, { checkDMS: true }) accepts longitudes such as 181° 0′ 0″ E and 799° 0′ 0″ W. The general degree pattern [1-7]?\d{1,2} also accepts 180, bypassing the dedicated branch that requires zero minutes and seconds.

Restrict the general longitude branch to 0–179 degrees and use the boundary branch for 180 degrees. Preserve fractional zero seconds at the boundary. The regression fixtures cover both hemispheres, fractional seconds, and the transitions around 99, 100, 179, and 180 degrees.

Reference: NOAA's longitude overview.

Validation on Node.js 24.19.0:

  • Full baseline npm test: 323 passing.
  • Tests without the source fix: 323 passing, 1 failing for an out-of-range DMS longitude.
  • Final npm test: 324 passing, including all builds, ESLint, and coverage.
  • 140,030 additional assertions passed across source, CommonJS, ES output loaded through Babel, browser, and minified browser forms.
  • git diff --check passed.

Prepared with Codex.

Checklist

  • Only related source and regression-test changes
  • README reviewed; no API or option changes
  • Regression tests added
  • Reference provided

@FanWu-ai
FanWu-ai marked this pull request as ready for review October 8, 2026 08:28
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.

1 participant