summaryrefslogtreecommitdiff
path: root/src/node_modules/validator/es/lib/isLatLong.js
blob: e081755f67cc95f6091d30c52f2b8d2cdd17ace5 (plain)
1
2
3
4
5
6
7
8
9
10
import assertString from './util/assertString';
var lat = /^\(?[+-]?(90(\.0+)?|[1-8]?\d(\.\d+)?)$/;
var _long = /^\s?[+-]?(180(\.0+)?|1[0-7]\d(\.\d+)?|\d{1,2}(\.\d+)?)\)?$/;
export default function (str) {
  assertString(str);
  if (!str.includes(',')) return false;
  var pair = str.split(',');
  if (pair[0].startsWith('(') && !pair[1].endsWith(')') || pair[1].endsWith(')') && !pair[0].startsWith('(')) return false;
  return lat.test(pair[0]) && _long.test(pair[1]);
}