summaryrefslogtreecommitdiff
path: root/src/node_modules/validator/es/lib/isLocale.js
blob: a7d6d2ede6a95f335a8414b61f8f78faf686bff8 (plain)
1
2
3
4
5
6
7
8
9
10
11
import assertString from './util/assertString';
var localeReg = /^[A-z]{2,4}([_-]([A-z]{4}|[\d]{3}))?([_-]([A-z]{2}|[\d]{3}))?$/;
export default function isLocale(str) {
  assertString(str);

  if (str === 'en_US_POSIX' || str === 'ca_ES_VALENCIA') {
    return true;
  }

  return localeReg.test(str);
}