Tiny dependency-free utility to provide coordinates validation written in TypeScript.
npm
npm install --save is-valid-coords
yarn
yarn add is-valid-coords
import isValidCoords from "is-valid-coords";
const latitude = 55.7558;
const longitude = 37.6173;
// true
isValidCoords(latitude, longitude);
isValidCoords(0, 0);
// false
isValidCoords(null);
isValidCoords();
import { getValidCoords } from "is-valid-coords";
// [latitude, longitude]
const coords1 = getValidCoords(55.7558, 37.6173);
// null
const coords2 = getValidCoords(100, 500);
// two arguments
isValidCoords(55.7558, 37.6173);
// array
isValidCoords([55.7558, 37.6173]);
// string
isValidCoords("55.7558, 37.6173");
// plain object with keys:
// - latitude, lat
// - longitude, lng, lon, long
isValidCoords({
latitude: 55.7558,
longitude: 37.6173
});