Validator.js: Expand validation for lat/long coordinates

Created on 12 Oct 2019  ·  4Comments  ·  Source: validatorjs/validator.js

Hi,

Thanks for this great library. Would like to request support for Lat/long coordinates with N,S,E,W and °

Potential examples:
26°11′N
26°11′N, 91°44′E
26°11′N 91°44′E

🙋‍♂️feature-request

Most helpful comment

Sounds good, perhaps this should come with an extra options param to support that. Just create a new regex for that as opposed to combining both regexes in to one.

All 4 comments

Yes currently only Signed degrees format is supported.
We can add validations for DMS + compass direction formats as well.
http://www.geomidpoint.com/latlon.html
@ezkemboi @profnandaa Happy to submit a PR for this one.

@rohankulshreshtha, sure. Do that, I will do a review.
I will also read the article send and also check on @smohiuddin issue on the same and provide more clarification.

I don't know what @profnandaa think?

Sounds good, perhaps this should come with an extra options param to support that. Just create a new regex for that as opposed to combining both regexes in to one.

I have added a PR for this one (#1158 ).
As discussed I have made a separate regex and introduced an option ({checkDMS : true}).
Latitudes, Longitudes range from 0 to 90, 0 to 180 respectively.
Minutes & Seconds range from 0-60.
N, S, E or W as last character(case insensitive).
Seconds can be a float.
Ex - '40° 26′ 46″ N, 79° 58′ 56″ W' or '40° 26′ 45.9996″ N, 79° 58′ 55.2″ E'
Please let me know if any change is required.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

karladler picture karladler  ·  3Comments

malkhuzayyim picture malkhuzayyim  ·  4Comments

frontendmonster picture frontendmonster  ·  4Comments

AnandChowdhary picture AnandChowdhary  ·  3Comments

rathboma picture rathboma  ·  4Comments