Skip to content

This simple utility verifies if a given coordinates is valid

License

Notifications You must be signed in to change notification settings

esteticalVE/is-valid-coords

 
 

Repository files navigation

isValidCoords

Build Status

Tiny dependency-free utility to provide coordinates validation written in TypeScript.

Install

npm

npm install --save is-valid-coords

yarn

yarn add is-valid-coords

Usage

isValidCoords

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();

getValidCoords

import { getValidCoords } from "is-valid-coords";

// [latitude, longitude]
const coords1 = getValidCoords(55.7558, 37.6173);

// null
const coords2 = getValidCoords(100, 500);

Variants

// 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
});

About

This simple utility verifies if a given coordinates is valid

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 95.5%
  • JavaScript 4.5%