diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 000000000..efa41e11e
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,33 @@
+name: CI
+on:
+ push:
+ branches: [master]
+ pull_request:
+ branches: [master]
+jobs:
+ test:
+ runs-on: ubuntu-20.04
+ strategy:
+ matrix:
+ node-version: [14, 12, 10, 8, 6]
+ name: Run tests on Node.js ${{ matrix.node-version }}
+ steps:
+ - name: Setup Node.js ${{ matrix.node-version }}
+ uses: actions/setup-node@v2-beta
+ with:
+ node-version: ${{ matrix.node-version }}
+ check-latest: true
+ - name: Checkout repository
+ uses: actions/checkout@v2
+ - name: Install dependencies
+ run: npm install
+ - name: Run tests
+ run: npm test
+ - if: matrix.node-version == 14
+ name: Generate coverage file
+ run: npm run test:ci > coverage.lcov
+ - if: matrix.node-version == 14
+ name: Send coverage info to Codecov
+ uses: codecov/codecov-action@v1
+ with:
+ file: ./coverage.lcov
diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml
new file mode 100644
index 000000000..b4b62f1b9
--- /dev/null
+++ b/.github/workflows/npm-publish.yml
@@ -0,0 +1,24 @@
+name: NPM Publish
+on:
+ release:
+ types: [created]
+jobs:
+ publish:
+ runs-on: ubuntu-20.04
+ steps:
+ - name: Setup Node.js 14
+ uses: actions/setup-node@v2-beta
+ with:
+ node-version: 14
+ check-latest: true
+ registry-url: https://registry.npmjs.org/
+ - name: Checkout Repository
+ uses: actions/checkout@v2
+ - name: Install Dependencies
+ run: npm install
+ - name: Run Tests
+ run: npm test
+ - name: Publish Package to NPM Registry
+ run: npm publish
+ env:
+ NODE_AUTH_TOKEN: ${{secrets.NPM_SECRET}}
diff --git a/.gitignore b/.gitignore
index 02f031234..9c8fa47bf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,6 @@ package-lock.json
yarn.lock
/es
/lib
+/index.js
validator.js
validator.min.js
-index.js
diff --git a/.nycrc b/.nycrc
index 27bf7b772..6b79f893c 100644
--- a/.nycrc
+++ b/.nycrc
@@ -5,9 +5,5 @@
],
"include": [
"src/**/*.js"
- ],
- "exclude": [
- "validator.js",
- "lib/**/*.js"
]
}
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 356e06912..000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-language: node_js
-node_js:
- - stable
- - 12
- - 11
- - 10
- - 9
- - 8
- - 6
-notifications:
- email: false
-after_success:
- - npm install -g codecov
- - npm run test:ci > coverage.lcov && codecov
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 826f6ef83..aec8e38fb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,48 @@
-#### 13.5.0
+#### 13.6.1
+
+- **New features**:
+ - [#1495](https://github.com/validatorjs/validator.js/pull/1495) `isLicensePlate` @firlus
+
+- **Fixes and Enhancements**:
+ - [#1651](https://github.com/validatorjs/validator.js/pull/1651) fix ReDOS vulnerabilities in `isHSL` and `isEmail` @tux-tn
+ - [#1644](https://github.com/validatorjs/validator.js/pull/1644) `isURL`: Allow URLs to have only a username in the userinfo subcomponent @jbuchmann-coosto
+ - [#1633](https://github.com/validatorjs/validator.js/pull/1633) `isISIN`: optimization @bmacnaughton
+ - [#1632](https://github.com/validatorjs/validator.js/pull/1632) `isIP`: improved pattern for IPv4 and IPv6 @ognjenjevremovic
+ - [#1625](https://github.com/validatorjs/validator.js/pull/1625) fix `[A-z]` regex range on some validators @bmacnaughton
+ - [#1620](https://github.com/validatorjs/validator.js/pull/1620) fix docs @prahaladbelavadi
+ - [#1616](https://github.com/validatorjs/validator.js/pull/1616) `isMacAddress`: improve regexes and options @fedeci
+ - [#1603](https://github.com/validatorjs/validator.js/pull/1603) fix ReDOS vulnerabilities in `isSlug` and `rtrim` @fedeci
+ - [#1594](https://github.com/validatorjs/validator.js/pull/1594) `isIPRange`: add support for IPv6 @neilime
+ - [#1577](https://github.com/validatorjs/validator.js/pull/1577) `isEAN`: add support for EAN-14 @varsubham @tux-tn
+ - [#1566](https://github.com/validatorjs/validator.js/pull/1566) `isStrongPassword`: add `@` as a valid symbol @stingalleman
+ - [#1548](https://github.com/validatorjs/validator.js/pull/1548) `isBtcAddress`: add base58 @ezkemboi
+ - [#1546](https://github.com/validatorjs/validator.js/pull/1546) `isFQDN`: numeric domain names @tux-tn
+
+- **New and Improved locales**:
+ - `isIdentityCard`, `isPassportNumber`:
+ - [#1595](https://github.com/validatorjs/validator.js/pull/1595) `IR` @mhf-ir @fedeci
+ - [#1583](https://github.com/validatorjs/validator.js/pull/1583) `ar-LY` @asghaier76 @tux-tn
+ - [#1574](https://github.com/validatorjs/validator.js/pull/1574) `MY` @stranger26 @tux-tn
+ - `isMobilePhone`:
+ - [#1642](https://github.com/validatorjs/validator.js/pull/1642) `zh-CN` @Akira0705
+ - [#1638](https://github.com/validatorjs/validator.js/pull/1638) `lv-LV` @AntonLukichev
+ - [#1635](https://github.com/validatorjs/validator.js/pull/1635) `en-GH` @ankorGH
+ - [#1604](https://github.com/validatorjs/validator.js/pull/1604) `mz-MZ` @salmento @tux-tn
+ - [#1575](https://github.com/validatorjs/validator.js/pull/1575) `vi-VN` @kyled7
+ - [#1573](https://github.com/validatorjs/validator.js/pull/1573) `en-SG` @liliwei25
+ - [#1554](https://github.com/validatorjs/validator.js/pull/1554) `de-CH`, `fr-CH`, `it-CH` @dinfekted
+ - [#1541](https://github.com/validatorjs/validator.js/pull/1541) [#1623](https://github.com/validatorjs/validator.js/pull/1623) `es-CO` @ezkemboi @tux-tn
+ - [#1506](https://github.com/validatorjs/validator.js/pull/1506) `ar-OM` @dev-sna
+ - [#1505](https://github.com/validatorjs/validator.js/pull/1505) `pt-AO` @AdilsonFuxe
+ - `isPostalCode`:
+ - [#1628](https://github.com/validatorjs/validator.js/pull/1628) `KR` @greatSumini
+ - `isTaxID`:
+ - [#1613](https://github.com/validatorjs/validator.js/pull/1613) `pt-BR` @mschunke
+ - [#1529](https://github.com/validatorjs/validator.js/pull/1529) `el-GR` @dspinellis
+ - `isVAT`:
+ - [#1536](https://github.com/validatorjs/validator.js/pull/1536) `IT` @fedeci
+
+#### ~~13.5.0~~ 13.5.1
- **New features**:
- `isVAT` [#1463](https://github.com/validatorjs/validator.js/pull/1463) @ CodingNagger
@@ -84,441 +128,441 @@
#### 13.1.1
- Hotfix for a regex incompatibility in some browsers
- ([#1355](https://github.com/chriso/validator.js/pull/1355)
+ ([#1355](https://github.com/validatorjs/validator.js/pull/1355)
#### 13.1.0
- Added an `isIMEI()` validator
- ([#1346](https://github.com/chriso/validator.js/pull/1346))
+ ([#1346](https://github.com/validatorjs/validator.js/pull/1346))
- Added an `isDate()` validator
- ([#1270](https://github.com/chriso/validator.js/pull/1270))
+ ([#1270](https://github.com/validatorjs/validator.js/pull/1270))
- Added an `isTaxID()` validator
- ([#1336](https://github.com/chriso/validator.js/pull/1336))
+ ([#1336](https://github.com/validatorjs/validator.js/pull/1336))
- Added DMS support to `isLatLong()`
- ([#1340](https://github.com/chriso/validator.js/pull/1340))
+ ([#1340](https://github.com/validatorjs/validator.js/pull/1340))
- Added support for URL-safe base64 validation
- ([#1277](https://github.com/chriso/validator.js/pull/1277))
+ ([#1277](https://github.com/validatorjs/validator.js/pull/1277))
- Added support for primitives in `isJSON()`
- ([#1328](https://github.com/chriso/validator.js/pull/1328))
+ ([#1328](https://github.com/validatorjs/validator.js/pull/1328))
- Added support for case-insensitive matching to `contains()`
- ([#1334](https://github.com/chriso/validator.js/pull/1334))
+ ([#1334](https://github.com/validatorjs/validator.js/pull/1334))
- Support additional cards in `isCreditCard()`
- ([#1177](https://github.com/chriso/validator.js/pull/1177))
+ ([#1177](https://github.com/validatorjs/validator.js/pull/1177))
- Support additional currencies in `isCurrency()`
- ([#1306](https://github.com/chriso/validator.js/pull/1306))
+ ([#1306](https://github.com/validatorjs/validator.js/pull/1306))
- Fixed `isFQDN()` handling of certain special chars
- ([#1091](https://github.com/chriso/validator.js/pull/1091))
+ ([#1091](https://github.com/validatorjs/validator.js/pull/1091))
- Fixed a bug in `isSlug()`
- ([#1338](https://github.com/chriso/validator.js/pull/1338))
+ ([#1338](https://github.com/validatorjs/validator.js/pull/1338))
- New and improved locales
- ([#1112](https://github.com/chriso/validator.js/pull/1112),
- [#1167](https://github.com/chriso/validator.js/pull/1167),
- [#1198](https://github.com/chriso/validator.js/pull/1198),
- [#1199](https://github.com/chriso/validator.js/pull/1199),
- [#1273](https://github.com/chriso/validator.js/pull/1273),
- [#1279](https://github.com/chriso/validator.js/pull/1279),
- [#1281](https://github.com/chriso/validator.js/pull/1281),
- [#1293](https://github.com/chriso/validator.js/pull/1293),
- [#1294](https://github.com/chriso/validator.js/pull/1294),
- [#1311](https://github.com/chriso/validator.js/pull/1311),
- [#1312](https://github.com/chriso/validator.js/pull/1312),
- [#1313](https://github.com/chriso/validator.js/pull/1313),
- [#1314](https://github.com/chriso/validator.js/pull/1314),
- [#1315](https://github.com/chriso/validator.js/pull/1315),
- [#1317](https://github.com/chriso/validator.js/pull/1317),
- [#1322](https://github.com/chriso/validator.js/pull/1322),
- [#1324](https://github.com/chriso/validator.js/pull/1324),
- [#1330](https://github.com/chriso/validator.js/pull/1330),
- [#1337](https://github.com/chriso/validator.js/pull/1337))
+ ([#1112](https://github.com/validatorjs/validator.js/pull/1112),
+ [#1167](https://github.com/validatorjs/validator.js/pull/1167),
+ [#1198](https://github.com/validatorjs/validator.js/pull/1198),
+ [#1199](https://github.com/validatorjs/validator.js/pull/1199),
+ [#1273](https://github.com/validatorjs/validator.js/pull/1273),
+ [#1279](https://github.com/validatorjs/validator.js/pull/1279),
+ [#1281](https://github.com/validatorjs/validator.js/pull/1281),
+ [#1293](https://github.com/validatorjs/validator.js/pull/1293),
+ [#1294](https://github.com/validatorjs/validator.js/pull/1294),
+ [#1311](https://github.com/validatorjs/validator.js/pull/1311),
+ [#1312](https://github.com/validatorjs/validator.js/pull/1312),
+ [#1313](https://github.com/validatorjs/validator.js/pull/1313),
+ [#1314](https://github.com/validatorjs/validator.js/pull/1314),
+ [#1315](https://github.com/validatorjs/validator.js/pull/1315),
+ [#1317](https://github.com/validatorjs/validator.js/pull/1317),
+ [#1322](https://github.com/validatorjs/validator.js/pull/1322),
+ [#1324](https://github.com/validatorjs/validator.js/pull/1324),
+ [#1330](https://github.com/validatorjs/validator.js/pull/1330),
+ [#1337](https://github.com/validatorjs/validator.js/pull/1337))
#### 13.0.0
- Added `isEthereumAddress()` validator
to validate [Ethereum addresses](https://en.wikipedia.org/wiki/Ethereum#Addresses)
- ([#1117](https://github.com/chriso/validator.js/pull/1117))
+ ([#1117](https://github.com/validatorjs/validator.js/pull/1117))
- Added `isBtcAddress()` validator
to validate [Bitcoin addresses](https://en.bitcoin.it/wiki/Address)
- ([#1163](https://github.com/chriso/validator.js/pull/1163))
+ ([#1163](https://github.com/validatorjs/validator.js/pull/1163))
- Added `isIBAN()` validator
to validate [International Bank Account Numbers](https://en.wikipedia.org/wiki/International_Bank_Account_Number)
- ([#1243](https://github.com/chriso/validator.js/pull/1243))
+ ([#1243](https://github.com/validatorjs/validator.js/pull/1243))
- Added `isEAN()` validator
to validate [International Article Numbers](https://en.wikipedia.org/wiki/International_Article_Number)
- ([#1244](https://github.com/chriso/validator.js/pull/1244))
+ ([#1244](https://github.com/validatorjs/validator.js/pull/1244))
- Added `isSemVer()` validator
to validate [Semantic Version Numbers](https://semver.org)
- ([#1246](https://github.com/chriso/validator.js/pull/1246))
+ ([#1246](https://github.com/validatorjs/validator.js/pull/1246))
- Added `isPassportNumber()` validator
- ([#1250](https://github.com/chriso/validator.js/pull/1250))
+ ([#1250](https://github.com/validatorjs/validator.js/pull/1250))
- Added `isRgbColor()` validator
- ([#1141](https://github.com/chriso/validator.js/pull/1141))
+ ([#1141](https://github.com/validatorjs/validator.js/pull/1141))
- Added `isHSL()` validator
- ([#1159](https://github.com/chriso/validator.js/pull/1159))
+ ([#1159](https://github.com/validatorjs/validator.js/pull/1159))
- Added `isLocale()` validator
- ([#1072](https://github.com/chriso/validator.js/pull/1072))
+ ([#1072](https://github.com/validatorjs/validator.js/pull/1072))
- Improved the `isIP()` validator
- ([#1211](https://github.com/chriso/validator.js/pull/1211))
+ ([#1211](https://github.com/validatorjs/validator.js/pull/1211))
- Improved the `isMACAddress()` validator
- ([#1267](https://github.com/chriso/validator.js/pull/1267))
+ ([#1267](https://github.com/validatorjs/validator.js/pull/1267))
- New and improved locales
- ([#1238](https://github.com/chriso/validator.js/pull/1238),
- [#1265](https://github.com/chriso/validator.js/pull/1265))
+ ([#1238](https://github.com/validatorjs/validator.js/pull/1238),
+ [#1265](https://github.com/validatorjs/validator.js/pull/1265))
#### 12.2.0
- Support CSS Colors Level 4 spec
- ([#1233](https://github.com/chriso/validator.js/pull/1233))
+ ([#1233](https://github.com/validatorjs/validator.js/pull/1233))
- Improve the `toFloat()` sanitizer
- ([#1227](https://github.com/chriso/validator.js/pull/1227))
+ ([#1227](https://github.com/validatorjs/validator.js/pull/1227))
- New and improved locales
- ([#1200](https://github.com/chriso/validator.js/pull/1200),
- [#1207](https://github.com/chriso/validator.js/pull/1207),
- [#1213](https://github.com/chriso/validator.js/pull/1213),
- [#1217](https://github.com/chriso/validator.js/pull/1217),
- [#1234](https://github.com/chriso/validator.js/pull/1234))
+ ([#1200](https://github.com/validatorjs/validator.js/pull/1200),
+ [#1207](https://github.com/validatorjs/validator.js/pull/1207),
+ [#1213](https://github.com/validatorjs/validator.js/pull/1213),
+ [#1217](https://github.com/validatorjs/validator.js/pull/1217),
+ [#1234](https://github.com/validatorjs/validator.js/pull/1234))
#### 12.1.0
- ES module for webpack tree shaking
- ([#1015](https://github.com/chriso/validator.js/pull/1015))
+ ([#1015](https://github.com/validatorjs/validator.js/pull/1015))
- Updated `isIP()` to accept scoped IPv6 addresses
- ([#1160](https://github.com/chriso/validator.js/pull/1160))
+ ([#1160](https://github.com/validatorjs/validator.js/pull/1160))
- New and improved locales
- ([#1162](https://github.com/chriso/validator.js/pull/1162),
- [#1183](https://github.com/chriso/validator.js/pull/1183),
- [#1187](https://github.com/chriso/validator.js/pull/1187),
- [#1191](https://github.com/chriso/validator.js/pull/1191))
+ ([#1162](https://github.com/validatorjs/validator.js/pull/1162),
+ [#1183](https://github.com/validatorjs/validator.js/pull/1183),
+ [#1187](https://github.com/validatorjs/validator.js/pull/1187),
+ [#1191](https://github.com/validatorjs/validator.js/pull/1191))
#### 12.0.0
- Added `isOctal()` validator
- ([#1153](https://github.com/chriso/validator.js/pull/1153))
+ ([#1153](https://github.com/validatorjs/validator.js/pull/1153))
- Added `isSlug()` validator
- ([#1096](https://github.com/chriso/validator.js/pull/1096))
+ ([#1096](https://github.com/validatorjs/validator.js/pull/1096))
- Added `isBIC()` validator for bank identification codes
- ([#1071](https://github.com/chriso/validator.js/pull/1071))
+ ([#1071](https://github.com/validatorjs/validator.js/pull/1071))
- Allow uppercase chars in `isHash()`
- ([#1062](https://github.com/chriso/validator.js/pull/1062))
+ ([#1062](https://github.com/validatorjs/validator.js/pull/1062))
- Allow additional prefixes in `isHexadecimal()`
- ([#1147](https://github.com/chriso/validator.js/pull/1147))
+ ([#1147](https://github.com/validatorjs/validator.js/pull/1147))
- Allow additional separators in `isMACAddress()`
- ([#1065](https://github.com/chriso/validator.js/pull/1065))
+ ([#1065](https://github.com/validatorjs/validator.js/pull/1065))
- Better defaults for `isLength()`
- ([#1070](https://github.com/chriso/validator.js/pull/1070))
+ ([#1070](https://github.com/validatorjs/validator.js/pull/1070))
- Bug fixes
- ([#1074](https://github.com/chriso/validator.js/pull/1074))
+ ([#1074](https://github.com/validatorjs/validator.js/pull/1074))
- New and improved locales
- ([#1059](https://github.com/chriso/validator.js/pull/1059),
- [#1060](https://github.com/chriso/validator.js/pull/1060),
- [#1069](https://github.com/chriso/validator.js/pull/1069),
- [#1073](https://github.com/chriso/validator.js/pull/1073),
- [#1082](https://github.com/chriso/validator.js/pull/1082),
- [#1092](https://github.com/chriso/validator.js/pull/1092),
- [#1121](https://github.com/chriso/validator.js/pull/1121),
- [#1125](https://github.com/chriso/validator.js/pull/1125),
- [#1132](https://github.com/chriso/validator.js/pull/1132),
- [#1152](https://github.com/chriso/validator.js/pull/1152),
- [#1165](https://github.com/chriso/validator.js/pull/1165),
- [#1166](https://github.com/chriso/validator.js/pull/1166),
- [#1174](https://github.com/chriso/validator.js/pull/1174))
+ ([#1059](https://github.com/validatorjs/validator.js/pull/1059),
+ [#1060](https://github.com/validatorjs/validator.js/pull/1060),
+ [#1069](https://github.com/validatorjs/validator.js/pull/1069),
+ [#1073](https://github.com/validatorjs/validator.js/pull/1073),
+ [#1082](https://github.com/validatorjs/validator.js/pull/1082),
+ [#1092](https://github.com/validatorjs/validator.js/pull/1092),
+ [#1121](https://github.com/validatorjs/validator.js/pull/1121),
+ [#1125](https://github.com/validatorjs/validator.js/pull/1125),
+ [#1132](https://github.com/validatorjs/validator.js/pull/1132),
+ [#1152](https://github.com/validatorjs/validator.js/pull/1152),
+ [#1165](https://github.com/validatorjs/validator.js/pull/1165),
+ [#1166](https://github.com/validatorjs/validator.js/pull/1166),
+ [#1174](https://github.com/validatorjs/validator.js/pull/1174))
#### 11.1.0
- Code coverage improvements
- ([#1024](https://github.com/chriso/validator.js/pull/1024))
+ ([#1024](https://github.com/validatorjs/validator.js/pull/1024))
- New and improved locales
- ([#1035](https://github.com/chriso/validator.js/pull/1035),
- [#1040](https://github.com/chriso/validator.js/pull/1040),
- [#1041](https://github.com/chriso/validator.js/pull/1041),
- [#1048](https://github.com/chriso/validator.js/pull/1048),
- [#1049](https://github.com/chriso/validator.js/pull/1049),
- [#1052](https://github.com/chriso/validator.js/pull/1052),
- [#1054](https://github.com/chriso/validator.js/pull/1054),
- [#1055](https://github.com/chriso/validator.js/pull/1055),
- [#1056](https://github.com/chriso/validator.js/pull/1056),
- [#1057](https://github.com/chriso/validator.js/pull/1057))
+ ([#1035](https://github.com/validatorjs/validator.js/pull/1035),
+ [#1040](https://github.com/validatorjs/validator.js/pull/1040),
+ [#1041](https://github.com/validatorjs/validator.js/pull/1041),
+ [#1048](https://github.com/validatorjs/validator.js/pull/1048),
+ [#1049](https://github.com/validatorjs/validator.js/pull/1049),
+ [#1052](https://github.com/validatorjs/validator.js/pull/1052),
+ [#1054](https://github.com/validatorjs/validator.js/pull/1054),
+ [#1055](https://github.com/validatorjs/validator.js/pull/1055),
+ [#1056](https://github.com/validatorjs/validator.js/pull/1056),
+ [#1057](https://github.com/validatorjs/validator.js/pull/1057))
#### 11.0.0
- Added a `isBase32()` validator
- ([#1023](https://github.com/chriso/validator.js/pull/1023))
+ ([#1023](https://github.com/validatorjs/validator.js/pull/1023))
- Updated `isEmail()` to validate display names according to RFC2822
- ([#1004](https://github.com/chriso/validator.js/pull/1004))
+ ([#1004](https://github.com/validatorjs/validator.js/pull/1004))
- Updated `isEmail()` to check total email length
- ([#1007](https://github.com/chriso/validator.js/pull/1007))
+ ([#1007](https://github.com/validatorjs/validator.js/pull/1007))
- The internal `toString()` util is no longer exported
- ([0277eb](https://github.com/chriso/validator.js/commit/0277eb00d245a3479af52adf7d927d4036895650))
+ ([0277eb](https://github.com/validatorjs/validator.js/commit/0277eb00d245a3479af52adf7d927d4036895650))
- New and improved locales
- ([#999](https://github.com/chriso/validator.js/pull/999),
- [#1010](https://github.com/chriso/validator.js/pull/1010),
- [#1017](https://github.com/chriso/validator.js/pull/1017),
- [#1022](https://github.com/chriso/validator.js/pull/1022),
- [#1031](https://github.com/chriso/validator.js/pull/1031),
- [#1032](https://github.com/chriso/validator.js/pull/1032))
+ ([#999](https://github.com/validatorjs/validator.js/pull/999),
+ [#1010](https://github.com/validatorjs/validator.js/pull/1010),
+ [#1017](https://github.com/validatorjs/validator.js/pull/1017),
+ [#1022](https://github.com/validatorjs/validator.js/pull/1022),
+ [#1031](https://github.com/validatorjs/validator.js/pull/1031),
+ [#1032](https://github.com/validatorjs/validator.js/pull/1032))
#### 10.11.0
- Fix imports like `import .. from "validator/lib/.."`
- ([#961](https://github.com/chriso/validator.js/pull/961))
+ ([#961](https://github.com/validatorjs/validator.js/pull/961))
- New locale
- ([#958](https://github.com/chriso/validator.js/pull/958))
+ ([#958](https://github.com/validatorjs/validator.js/pull/958))
#### 10.10.0
- `isISO8601()` strict mode now works in the browser
- ([#932](https://github.com/chriso/validator.js/pull/932))
+ ([#932](https://github.com/validatorjs/validator.js/pull/932))
- New and improved locales
- ([#931](https://github.com/chriso/validator.js/pull/931),
- [#933](https://github.com/chriso/validator.js/pull/933),
- [#947](https://github.com/chriso/validator.js/pull/947),
- [#950](https://github.com/chriso/validator.js/pull/950))
+ ([#931](https://github.com/validatorjs/validator.js/pull/931),
+ [#933](https://github.com/validatorjs/validator.js/pull/933),
+ [#947](https://github.com/validatorjs/validator.js/pull/947),
+ [#950](https://github.com/validatorjs/validator.js/pull/950))
#### 10.9.0
- Added an option to `isURL()` to reject email-like URLs
- ([#901](https://github.com/chriso/validator.js/pull/901))
+ ([#901](https://github.com/validatorjs/validator.js/pull/901))
- Added a `strict` option to `isISO8601()`
- ([#910](https://github.com/chriso/validator.js/pull/910))
+ ([#910](https://github.com/validatorjs/validator.js/pull/910))
- Relaxed `isJWT()` signature requirements
- ([#906](https://github.com/chriso/validator.js/pull/906))
+ ([#906](https://github.com/validatorjs/validator.js/pull/906))
- New and improved locales
- ([#899](https://github.com/chriso/validator.js/pull/899),
- [#904](https://github.com/chriso/validator.js/pull/904),
- [#913](https://github.com/chriso/validator.js/pull/913),
- [#916](https://github.com/chriso/validator.js/pull/916),
- [#925](https://github.com/chriso/validator.js/pull/925),
- [#928](https://github.com/chriso/validator.js/pull/928))
+ ([#899](https://github.com/validatorjs/validator.js/pull/899),
+ [#904](https://github.com/validatorjs/validator.js/pull/904),
+ [#913](https://github.com/validatorjs/validator.js/pull/913),
+ [#916](https://github.com/validatorjs/validator.js/pull/916),
+ [#925](https://github.com/validatorjs/validator.js/pull/925),
+ [#928](https://github.com/validatorjs/validator.js/pull/928))
#### 10.8.0
- Added `isIdentityCard()`
- ([#846](https://github.com/chriso/validator.js/pull/846))
+ ([#846](https://github.com/validatorjs/validator.js/pull/846))
- Better error when validators are passed an invalid type
- ([#895](https://github.com/chriso/validator.js/pull/895))
+ ([#895](https://github.com/validatorjs/validator.js/pull/895))
- Locales are now exported
- ([#890](https://github.com/chriso/validator.js/pull/890),
- [#892](https://github.com/chriso/validator.js/pull/892))
+ ([#890](https://github.com/validatorjs/validator.js/pull/890),
+ [#892](https://github.com/validatorjs/validator.js/pull/892))
- New locale
- ([#896](https://github.com/chriso/validator.js/pull/896))
+ ([#896](https://github.com/validatorjs/validator.js/pull/896))
#### 10.7.1
- Ignore case when checking URL protocol
- ([#887](https://github.com/chriso/validator.js/issues/887))
+ ([#887](https://github.com/validatorjs/validator.js/issues/887))
- Locale fix
- ([#889](https://github.com/chriso/validator.js/pull/889))
+ ([#889](https://github.com/validatorjs/validator.js/pull/889))
#### 10.7.0
- Added `isMagnetURI()` to validate [magnet URIs](https://en.wikipedia.org/wiki/Magnet_URI_scheme)
- ([#884](https://github.com/chriso/validator.js/pull/884))
+ ([#884](https://github.com/validatorjs/validator.js/pull/884))
- Added `isJWT()` to validate [JSON web tokens](https://en.wikipedia.org/wiki/JSON_Web_Token)
- ([#885](https://github.com/chriso/validator.js/pull/885))
+ ([#885](https://github.com/validatorjs/validator.js/pull/885))
#### 10.6.0
- Updated `isMobilePhone()` to match any locale's pattern by default
- ([#874](https://github.com/chriso/validator.js/pull/874))
+ ([#874](https://github.com/validatorjs/validator.js/pull/874))
- Added an option to ignore whitespace in `isEmpty()`
- ([#880](https://github.com/chriso/validator.js/pull/880))
+ ([#880](https://github.com/validatorjs/validator.js/pull/880))
- New and improved locales
- ([#878](https://github.com/chriso/validator.js/pull/878),
- [#879](https://github.com/chriso/validator.js/pull/879))
+ ([#878](https://github.com/validatorjs/validator.js/pull/878),
+ [#879](https://github.com/validatorjs/validator.js/pull/879))
#### 10.5.0
- Disabled domain-specific email validation
- ([#873](https://github.com/chriso/validator.js/pull/873))
+ ([#873](https://github.com/validatorjs/validator.js/pull/873))
- Added support for IP hostnames in `isEmail()`
- ([#845](https://github.com/chriso/validator.js/pull/845))
+ ([#845](https://github.com/validatorjs/validator.js/pull/845))
- Added a `no_symbols` option to `isNumeric()`
- ([#848](https://github.com/chriso/validator.js/pull/848))
+ ([#848](https://github.com/validatorjs/validator.js/pull/848))
- Added a `no_colons` option to `isMACAddress()`
- ([#849](https://github.com/chriso/validator.js/pull/849))
+ ([#849](https://github.com/validatorjs/validator.js/pull/849))
- Updated `isURL()` to reject protocol relative URLs unless a flag is set
- ([#860](https://github.com/chriso/validator.js/issues/860))
+ ([#860](https://github.com/validatorjs/validator.js/issues/860))
- New and improved locales
- ([#801](https://github.com/chriso/validator.js/pull/801),
- [#856](https://github.com/chriso/validator.js/pull/856),
- [#859](https://github.com/chriso/validator.js/issues/859),
- [#861](https://github.com/chriso/validator.js/pull/861),
- [#862](https://github.com/chriso/validator.js/pull/862),
- [#863](https://github.com/chriso/validator.js/pull/863),
- [#864](https://github.com/chriso/validator.js/pull/864),
- [#870](https://github.com/chriso/validator.js/pull/870),
- [#872](https://github.com/chriso/validator.js/pull/872))
+ ([#801](https://github.com/validatorjs/validator.js/pull/801),
+ [#856](https://github.com/validatorjs/validator.js/pull/856),
+ [#859](https://github.com/validatorjs/validator.js/issues/859),
+ [#861](https://github.com/validatorjs/validator.js/pull/861),
+ [#862](https://github.com/validatorjs/validator.js/pull/862),
+ [#863](https://github.com/validatorjs/validator.js/pull/863),
+ [#864](https://github.com/validatorjs/validator.js/pull/864),
+ [#870](https://github.com/validatorjs/validator.js/pull/870),
+ [#872](https://github.com/validatorjs/validator.js/pull/872))
#### 10.4.0
- Added an `isIPRange()` validator
- ([#842](https://github.com/chriso/validator.js/pull/842))
+ ([#842](https://github.com/validatorjs/validator.js/pull/842))
- Accept an array of locales in `isMobilePhone()`
- ([#742](https://github.com/chriso/validator.js/pull/742))
+ ([#742](https://github.com/validatorjs/validator.js/pull/742))
- New locale
- ([#843](https://github.com/chriso/validator.js/pull/843))
+ ([#843](https://github.com/validatorjs/validator.js/pull/843))
#### 10.3.0
- Strict Gmail validation in `isEmail()`
- ([#832](https://github.com/chriso/validator.js/pull/832))
+ ([#832](https://github.com/validatorjs/validator.js/pull/832))
- New locales
- ([#831](https://github.com/chriso/validator.js/pull/831),
- [#835](https://github.com/chriso/validator.js/pull/835),
- [#836](https://github.com/chriso/validator.js/pull/836))
+ ([#831](https://github.com/validatorjs/validator.js/pull/831),
+ [#835](https://github.com/validatorjs/validator.js/pull/835),
+ [#836](https://github.com/validatorjs/validator.js/pull/836))
#### 10.2.0
- Export the list of supported locales in `isPostalCode()`
- ([#830](https://github.com/chriso/validator.js/pull/830))
+ ([#830](https://github.com/validatorjs/validator.js/pull/830))
#### 10.1.0
- Added an `isISO31661Alpha3()` validator
- ([#809](https://github.com/chriso/validator.js/pull/809))
+ ([#809](https://github.com/validatorjs/validator.js/pull/809))
#### 10.0.0
- Allow floating points in `isNumeric()`
- ([#810](https://github.com/chriso/validator.js/pull/810))
+ ([#810](https://github.com/validatorjs/validator.js/pull/810))
- Disallow GMail addresses with multiple consecutive dots, or leading/trailing dots
- ([#820](https://github.com/chriso/validator.js/pull/820))
+ ([#820](https://github.com/validatorjs/validator.js/pull/820))
- Added an `isRFC3339()` validator
- ([#816](https://github.com/chriso/validator.js/pull/816))
+ ([#816](https://github.com/validatorjs/validator.js/pull/816))
- Reject domain parts longer than 63 octets in `isFQDN()`, `isURL()` and `isEmail()`
- ([bb3e542](https://github.com/chriso/validator.js/commit/bb3e542))
+ ([bb3e542](https://github.com/validatorjs/validator.js/commit/bb3e542))
- Added a new Amex prefix to `isCreditCard()`
- ([#805](https://github.com/chriso/validator.js/pull/805))
+ ([#805](https://github.com/validatorjs/validator.js/pull/805))
- Fixed `isFloat()` min/max/gt/lt filters when a locale with a comma decimal is used
- ([2b70821](https://github.com/chriso/validator.js/commit/2b70821))
+ ([2b70821](https://github.com/validatorjs/validator.js/commit/2b70821))
- Normalize Yandex emails
- ([#807](https://github.com/chriso/validator.js/pull/807))
+ ([#807](https://github.com/validatorjs/validator.js/pull/807))
- New locales
- ([#803](https://github.com/chriso/validator.js/pull/803))
+ ([#803](https://github.com/validatorjs/validator.js/pull/803))
#### 9.4.1
- Patched a [REDOS](https://en.wikipedia.org/wiki/ReDoS) vulnerability in `isDataURI`
- New and improved locales
- ([#788](https://github.com/chriso/validator.js/pull/788))
+ ([#788](https://github.com/validatorjs/validator.js/pull/788))
#### 9.4.0
- Added an option to `isMobilePhone` to require a country code
- ([#769](https://github.com/chriso/validator.js/pull/769))
+ ([#769](https://github.com/validatorjs/validator.js/pull/769))
- New and improved locales
- ([#785](https://github.com/chriso/validator.js/pull/785))
+ ([#785](https://github.com/validatorjs/validator.js/pull/785))
#### 9.3.0
- New and improved locales
- ([#763](https://github.com/chriso/validator.js/pull/763),
- [#768](https://github.com/chriso/validator.js/pull/768),
- [#774](https://github.com/chriso/validator.js/pull/774),
- [#777](https://github.com/chriso/validator.js/pull/777),
- [#779](https://github.com/chriso/validator.js/pull/779))
+ ([#763](https://github.com/validatorjs/validator.js/pull/763),
+ [#768](https://github.com/validatorjs/validator.js/pull/768),
+ [#774](https://github.com/validatorjs/validator.js/pull/774),
+ [#777](https://github.com/validatorjs/validator.js/pull/777),
+ [#779](https://github.com/validatorjs/validator.js/pull/779))
#### 9.2.0
- Added an `isMimeType()` validator
- ([#760](https://github.com/chriso/validator.js/pull/760))
+ ([#760](https://github.com/validatorjs/validator.js/pull/760))
- New and improved locales
- ([#753](https://github.com/chriso/validator.js/pull/753),
- [#755](https://github.com/chriso/validator.js/pull/755),
- [#764](https://github.com/chriso/validator.js/pull/764))
+ ([#753](https://github.com/validatorjs/validator.js/pull/753),
+ [#755](https://github.com/validatorjs/validator.js/pull/755),
+ [#764](https://github.com/validatorjs/validator.js/pull/764))
#### 9.1.2
- Fixed a bug with the `isFloat` validator
- ([#752](https://github.com/chriso/validator.js/pull/752))
+ ([#752](https://github.com/validatorjs/validator.js/pull/752))
#### 9.1.1
- Locale fixes
- ([#738](https://github.com/chriso/validator.js/pull/738),
- [#739](https://github.com/chriso/validator.js/pull/739))
+ ([#738](https://github.com/validatorjs/validator.js/pull/738),
+ [#739](https://github.com/validatorjs/validator.js/pull/739))
#### 9.1.0
- Added an `isISO31661Alpha2()` validator
- ([#734](https://github.com/chriso/validator.js/pull/734))
+ ([#734](https://github.com/validatorjs/validator.js/pull/734))
- New locales
- ([#735](https://github.com/chriso/validator.js/pull/735),
- [#737](https://github.com/chriso/validator.js/pull/737))
+ ([#735](https://github.com/validatorjs/validator.js/pull/735),
+ [#737](https://github.com/validatorjs/validator.js/pull/737))
#### 9.0.0
- `normalizeEmail()` no longer validates the email address
- ([#725](https://github.com/chriso/validator.js/pull/725))
+ ([#725](https://github.com/validatorjs/validator.js/pull/725))
- Added locale-aware validation to `isFloat()` and `isDecimal()`
- ([#721](https://github.com/chriso/validator.js/pull/721))
+ ([#721](https://github.com/validatorjs/validator.js/pull/721))
- Added an `isPort()` validator
- ([#733](https://github.com/chriso/validator.js/pull/733))
+ ([#733](https://github.com/validatorjs/validator.js/pull/733))
- New locales
- ([#731](https://github.com/chriso/validator.js/pull/731))
+ ([#731](https://github.com/validatorjs/validator.js/pull/731))
#### 8.2.0
- Added an `isHash()` validator
- ([#711](https://github.com/chriso/validator.js/pull/711))
+ ([#711](https://github.com/validatorjs/validator.js/pull/711))
- Control decimal places in `isCurrency()`
- ([#713](https://github.com/chriso/validator.js/pull/713))
+ ([#713](https://github.com/validatorjs/validator.js/pull/713))
- New and improved locales
- ([#700](https://github.com/chriso/validator.js/pull/700),
- [#701](https://github.com/chriso/validator.js/pull/701),
- [#714](https://github.com/chriso/validator.js/pull/714),
- [#715](https://github.com/chriso/validator.js/pull/715),
- [#718](https://github.com/chriso/validator.js/pull/718))
+ ([#700](https://github.com/validatorjs/validator.js/pull/700),
+ [#701](https://github.com/validatorjs/validator.js/pull/701),
+ [#714](https://github.com/validatorjs/validator.js/pull/714),
+ [#715](https://github.com/validatorjs/validator.js/pull/715),
+ [#718](https://github.com/validatorjs/validator.js/pull/718))
#### 8.1.0
- Fix `require('validator/lib/isIS8601')` calls
- ([#688](https://github.com/chriso/validator.js/issues/688))
+ ([#688](https://github.com/validatorjs/validator.js/issues/688))
- Added an `isLatLong()` and `isPostalCode()` validator
- ([#684](https://github.com/chriso/validator.js/pull/684))
+ ([#684](https://github.com/validatorjs/validator.js/pull/684))
- Allow comma in email display names
- ([#692](https://github.com/chriso/validator.js/pull/692))
+ ([#692](https://github.com/validatorjs/validator.js/pull/692))
- Add missing string to `unescape()`
- ([#690](https://github.com/chriso/validator.js/pull/690))
+ ([#690](https://github.com/validatorjs/validator.js/pull/690))
- Fix `isMobilePhone()` with Node <= 6.x
- ([#681](https://github.com/chriso/validator.js/issues/681))
+ ([#681](https://github.com/validatorjs/validator.js/issues/681))
- New locales
- ([#695](https://github.com/chriso/validator.js/pull/695))
+ ([#695](https://github.com/validatorjs/validator.js/pull/695))
#### 8.0.0
- `isURL()` now requires the `require_tld: false` option to validate `localhost`
- ([#675](https://github.com/chriso/validator.js/issues/675))
+ ([#675](https://github.com/validatorjs/validator.js/issues/675))
- `isURL()` now rejects URLs that are protocol only
- ([#642](https://github.com/chriso/validator.js/issues/642))
+ ([#642](https://github.com/validatorjs/validator.js/issues/642))
- Fixed a bug where `isMobilePhone()` would silently return false if the locale was invalid or unsupported
- ([#657](https://github.com/chriso/validator.js/issues/657))
+ ([#657](https://github.com/validatorjs/validator.js/issues/657))
#### 7.2.0
- Added an option to validate any phone locale
- ([#663](https://github.com/chriso/validator.js/pull/663))
+ ([#663](https://github.com/validatorjs/validator.js/pull/663))
- Fixed a bug in credit card validation
- ([#672](https://github.com/chriso/validator.js/pull/672))
+ ([#672](https://github.com/validatorjs/validator.js/pull/672))
- Disallow whitespace, including unicode whitespace, in TLDs
- ([#677](https://github.com/chriso/validator.js/pull/677))
+ ([#677](https://github.com/validatorjs/validator.js/pull/677))
- New locales
- ([#673](https://github.com/chriso/validator.js/pull/673),
- [#676](https://github.com/chriso/validator.js/pull/676))
+ ([#673](https://github.com/validatorjs/validator.js/pull/673),
+ [#676](https://github.com/validatorjs/validator.js/pull/676))
#### 7.1.0
- Added an `isISRC()` validator for [ISRC](https://en.wikipedia.org/wiki/International_Standard_Recording_Code)
- ([#660](https://github.com/chriso/validator.js/pull/660))
+ ([#660](https://github.com/validatorjs/validator.js/pull/660))
- Fixed a bug in credit card validation
- ([#670](https://github.com/chriso/validator.js/pull/670))
+ ([#670](https://github.com/validatorjs/validator.js/pull/670))
- Reduced the maximum allowed address in `isEmail()` based on
[RFC3696 errata](http://www.rfc-editor.org/errata_search.php?rfc=3696&eid=1690)
- ([#655](https://github.com/chriso/validator.js/issues/655))
+ ([#655](https://github.com/validatorjs/validator.js/issues/655))
- New locales
- ([#647](https://github.com/chriso/validator.js/pull/647),
- [#667](https://github.com/chriso/validator.js/pull/667),
- [#667](https://github.com/chriso/validator.js/pull/667),
- [#671](https://github.com/chriso/validator.js/pull/671))
+ ([#647](https://github.com/validatorjs/validator.js/pull/647),
+ [#667](https://github.com/validatorjs/validator.js/pull/667),
+ [#667](https://github.com/validatorjs/validator.js/pull/667),
+ [#671](https://github.com/validatorjs/validator.js/pull/671))
#### 7.0.0
@@ -527,290 +571,290 @@
#### 6.3.0
- Allow values like `-.01` in `isFloat()`
- ([#618](https://github.com/chriso/validator.js/issues/618))
+ ([#618](https://github.com/validatorjs/validator.js/issues/618))
- New locales
- ([#616](https://github.com/chriso/validator.js/pull/616),
- [#622](https://github.com/chriso/validator.js/pull/622),
- [#627](https://github.com/chriso/validator.js/pull/627),
- [#630](https://github.com/chriso/validator.js/pull/630))
+ ([#616](https://github.com/validatorjs/validator.js/pull/616),
+ [#622](https://github.com/validatorjs/validator.js/pull/622),
+ [#627](https://github.com/validatorjs/validator.js/pull/627),
+ [#630](https://github.com/validatorjs/validator.js/pull/630))
#### 6.2.1
- Disallow `<` and `>` in URLs
- ([#613](https://github.com/chriso/validator.js/issues/613))
+ ([#613](https://github.com/validatorjs/validator.js/issues/613))
- New locales
- ([#610](https://github.com/chriso/validator.js/pull/610))
+ ([#610](https://github.com/validatorjs/validator.js/pull/610))
#### 6.2.0
- Added an option to require an email display name
- ([#607](https://github.com/chriso/validator.js/pull/607))
+ ([#607](https://github.com/validatorjs/validator.js/pull/607))
- Added support for `lt` and `gt` to `isInt()`
- ([#588](https://github.com/chriso/validator.js/pull/588))
+ ([#588](https://github.com/validatorjs/validator.js/pull/588))
- New locales
- ([#601](https://github.com/chriso/validator.js/pull/601))
+ ([#601](https://github.com/validatorjs/validator.js/pull/601))
#### 6.1.0
- Added support for greater or less than in `isFloat()`
- ([#544](https://github.com/chriso/validator.js/issues/544))
+ ([#544](https://github.com/validatorjs/validator.js/issues/544))
- Added support for ISSN validation via `isISSN()`
- ([#593](https://github.com/chriso/validator.js/pull/593))
+ ([#593](https://github.com/validatorjs/validator.js/pull/593))
- Fixed a bug in `normalizeEmail()`
- ([#594](https://github.com/chriso/validator.js/issues/594))
+ ([#594](https://github.com/validatorjs/validator.js/issues/594))
- New locales
- ([#585](https://github.com/chriso/validator.js/pull/585))
+ ([#585](https://github.com/validatorjs/validator.js/pull/585))
#### 6.0.0
- Renamed `isNull()` to `isEmpty()`
- ([#574](https://github.com/chriso/validator.js/issues/574))
+ ([#574](https://github.com/validatorjs/validator.js/issues/574))
- Backslash is now escaped in `escape()`
- ([#516](https://github.com/chriso/validator.js/issues/516))
+ ([#516](https://github.com/validatorjs/validator.js/issues/516))
- Improved `normalizeEmail()`
- ([#583](https://github.com/chriso/validator.js/pull/583))
+ ([#583](https://github.com/validatorjs/validator.js/pull/583))
- Allow leading zeroes by default in `isInt()`
- ([#532](https://github.com/chriso/validator.js/pull/532))
+ ([#532](https://github.com/validatorjs/validator.js/pull/532))
#### 5.7.0
- Added support for IPv6 in `isURL()`
- ([#564](https://github.com/chriso/validator.js/issues/564))
+ ([#564](https://github.com/validatorjs/validator.js/issues/564))
- Added support for urls without a host (e.g. `file:///foo.txt`) in `isURL()`
- ([#563](https://github.com/chriso/validator.js/issues/563))
+ ([#563](https://github.com/validatorjs/validator.js/issues/563))
- Added support for regular expressions in the `isURL()` host whitelist and blacklist
- ([#562](https://github.com/chriso/validator.js/issues/562))
+ ([#562](https://github.com/validatorjs/validator.js/issues/562))
- Added support for MasterCard 2-Series BIN
- ([#576](https://github.com/chriso/validator.js/pull/576))
+ ([#576](https://github.com/validatorjs/validator.js/pull/576))
- New locales
- ([#575](https://github.com/chriso/validator.js/pull/575),
- [#552](https://github.com/chriso/validator.js/issues/552))
+ ([#575](https://github.com/validatorjs/validator.js/pull/575),
+ [#552](https://github.com/validatorjs/validator.js/issues/552))
#### 5.6.0
- Added an `isMD5()` validator
- ([#557](https://github.com/chriso/validator.js/pull/557))
+ ([#557](https://github.com/validatorjs/validator.js/pull/557))
- Fixed an exceptional case in `isDate()`
- ([#566](https://github.com/chriso/validator.js/pull/566))
+ ([#566](https://github.com/validatorjs/validator.js/pull/566))
- New locales
- ([#559](https://github.com/chriso/validator.js/pull/559),
- [#568](https://github.com/chriso/validator.js/pull/568),
- [#571](https://github.com/chriso/validator.js/pull/571),
- [#573](https://github.com/chriso/validator.js/pull/573))
+ ([#559](https://github.com/validatorjs/validator.js/pull/559),
+ [#568](https://github.com/validatorjs/validator.js/pull/568),
+ [#571](https://github.com/validatorjs/validator.js/pull/571),
+ [#573](https://github.com/validatorjs/validator.js/pull/573))
#### 5.5.0
- Fixed a regex denial of service in `trim()` and `rtrim()`
- ([#556](https://github.com/chriso/validator.js/pull/556))
+ ([#556](https://github.com/validatorjs/validator.js/pull/556))
- Added an Algerian locale to `isMobilePhone()`
- ([#540](https://github.com/chriso/validator.js/pull/540))
+ ([#540](https://github.com/validatorjs/validator.js/pull/540))
- Fixed the Hungarian locale in `isAlpha()` and `isAlphanumeric()`
- ([#541](https://github.com/chriso/validator.js/pull/541))
+ ([#541](https://github.com/validatorjs/validator.js/pull/541))
- Added a Polish locale to `isMobilePhone()`
- ([#545](https://github.com/chriso/validator.js/pull/545))
+ ([#545](https://github.com/validatorjs/validator.js/pull/545))
#### 5.4.0
- Accept Union Pay credit cards in `isCreditCard()`
- ([#539](https://github.com/chriso/validator.js/pull/539))
+ ([#539](https://github.com/validatorjs/validator.js/pull/539))
- Added Danish locale to `isMobilePhone()`
- ([#538](https://github.com/chriso/validator.js/pull/538))
+ ([#538](https://github.com/validatorjs/validator.js/pull/538))
- Added Hungarian locales to `isAlpha()`, `isAlphanumeric()` and `isMobilePhone()`
- ([#537](https://github.com/chriso/validator.js/pull/537))
+ ([#537](https://github.com/validatorjs/validator.js/pull/537))
#### 5.3.0
- Added an `allow_leading_zeroes` option to `isInt()`
- ([#532](https://github.com/chriso/validator.js/pull/532))
+ ([#532](https://github.com/validatorjs/validator.js/pull/532))
- Adjust Chinese mobile phone validation
- ([#523](https://github.com/chriso/validator.js/pull/523))
+ ([#523](https://github.com/validatorjs/validator.js/pull/523))
- Added a Canadian locale to `isMobilePhone()`
- ([#524](https://github.com/chriso/validator.js/issues/524))
+ ([#524](https://github.com/validatorjs/validator.js/issues/524))
#### 5.2.0
- Added a `isDataURI()` validator
- ([#521](https://github.com/chriso/validator.js/pull/521))
+ ([#521](https://github.com/validatorjs/validator.js/pull/521))
- Added Czech locales
- ([#522](https://github.com/chriso/validator.js/pull/522))
+ ([#522](https://github.com/validatorjs/validator.js/pull/522))
- Fixed a bug with `isURL()` when protocol was missing and "://" appeared in the query
- ([#518](https://github.com/chriso/validator.js/issues/518))
+ ([#518](https://github.com/validatorjs/validator.js/issues/518))
#### 5.1.0
- Added a `unescape()` HTML function
- ([#509](https://github.com/chriso/validator.js/pull/509))
+ ([#509](https://github.com/validatorjs/validator.js/pull/509))
- Added a Malaysian locale to `isMobilePhone()`
- ([#507](https://github.com/chriso/validator.js/pull/507))
+ ([#507](https://github.com/validatorjs/validator.js/pull/507))
- Added Polish locales to `isAlpha()` and `isAlphanumeric()`
- ([#506](https://github.com/chriso/validator.js/pull/506))
+ ([#506](https://github.com/validatorjs/validator.js/pull/506))
- Added Turkish locales to `isAlpha()`, `isAlphanumeric()` and `isMobilePhone()`
- ([#512](https://github.com/chriso/validator.js/pull/512))
+ ([#512](https://github.com/validatorjs/validator.js/pull/512))
- Allow >1 underscore in hostnames when using `allow_underscores`
- ([#510](https://github.com/chriso/validator.js/issues/510))
+ ([#510](https://github.com/validatorjs/validator.js/issues/510))
#### 5.0.0
- Migrate to ES6
- ([#496](https://github.com/chriso/validator.js/pull/496))
+ ([#496](https://github.com/validatorjs/validator.js/pull/496))
- Break the library up so that individual functions can be imported
- ([#496](https://github.com/chriso/validator.js/pull/496))
+ ([#496](https://github.com/validatorjs/validator.js/pull/496))
- Remove auto-coercion of input to a string
- ([#496](https://github.com/chriso/validator.js/pull/496))
+ ([#496](https://github.com/validatorjs/validator.js/pull/496))
- Remove the `extend()` function
- ([#496](https://github.com/chriso/validator.js/pull/496))
+ ([#496](https://github.com/validatorjs/validator.js/pull/496))
- Added Arabic locales to `isAlpha()` and `isAlphanumeric()`
- ([#496](https://github.com/chriso/validator.js/pull/496#issuecomment-184781730))
+ ([#496](https://github.com/validatorjs/validator.js/pull/496#issuecomment-184781730))
- Fix validation of very large base64 strings
- ([#503](https://github.com/chriso/validator.js/pull/503))
+ ([#503](https://github.com/validatorjs/validator.js/pull/503))
#### 4.9.0
- Added a Russian locale to `isAlpha()` and `isAlphanumeric()`
- ([#499](https://github.com/chriso/validator.js/pull/499))
+ ([#499](https://github.com/validatorjs/validator.js/pull/499))
- Remove the restriction on adjacent hyphens in hostnames
- ([#500](https://github.com/chriso/validator.js/issues/500))
+ ([#500](https://github.com/validatorjs/validator.js/issues/500))
#### 4.8.0
- Added Spanish, French, Portuguese and Dutch support for `isAlpha()` and `isAlphanumeric()`
- ([#492](https://github.com/chriso/validator.js/pull/492))
+ ([#492](https://github.com/validatorjs/validator.js/pull/492))
- Added a Brazilian locale to `isMobilePhone()`
- ([#489](https://github.com/chriso/validator.js/pull/489))
+ ([#489](https://github.com/validatorjs/validator.js/pull/489))
- Reject IPv4 addresses with invalid zero padding
- ([#490](https://github.com/chriso/validator.js/pull/490))
+ ([#490](https://github.com/validatorjs/validator.js/pull/490))
- Fix the client-side version when used with RequireJS
- ([#494](https://github.com/chriso/validator.js/issues/494))
+ ([#494](https://github.com/validatorjs/validator.js/issues/494))
#### 4.7.1
- Use [node-depd](https://github.com/dougwilson/nodejs-depd) to print deprecation notices
- ([#487](https://github.com/chriso/validator.js/issues/487))
+ ([#487](https://github.com/validatorjs/validator.js/issues/487))
#### 4.7.0
- Print a deprecation warning if validator input is not a string
- ([1f67e1e](https://github.com/chriso/validator.js/commit/1f67e1e15198c0ae735151290dc8dc2bf14da254)).
+ ([1f67e1e](https://github.com/validatorjs/validator.js/commit/1f67e1e15198c0ae735151290dc8dc2bf14da254)).
Note that this will be an error in v5.
- Added a German locale to `isMobilePhone()`, `isAlpha()` and `isAlphanumeric()`
- ([#477](https://github.com/chriso/validator.js/pull/477))
+ ([#477](https://github.com/validatorjs/validator.js/pull/477))
- Added a Finnish locale to `isMobilePhone()`
- ([#455](https://github.com/chriso/validator.js/pull/455))
+ ([#455](https://github.com/validatorjs/validator.js/pull/455))
#### 4.6.1
- Fix coercion of objects: `Object.toString()` is `[object Object]` not `""`
- ([a57f3c8](https://github.com/chriso/validator.js/commit/a57f3c843c715fba2664ee22ec80e9e28e88e0a6))
+ ([a57f3c8](https://github.com/validatorjs/validator.js/commit/a57f3c843c715fba2664ee22ec80e9e28e88e0a6))
#### 4.6.0
- Added a Spanish locale to `isMobilePhone()`
- ([#481](https://github.com/chriso/validator.js/pull/481))
+ ([#481](https://github.com/validatorjs/validator.js/pull/481))
- Fix string coercion of objects created with `Object.create(null)`
- ([#484](https://github.com/chriso/validator.js/issues/484))
+ ([#484](https://github.com/validatorjs/validator.js/issues/484))
#### 4.5.2
- Fix a timezone issue with short-form ISO 8601 dates, e.g.
`validator.isDate('2011-12-21')`
- ([#480](https://github.com/chriso/validator.js/issues/480))
+ ([#480](https://github.com/validatorjs/validator.js/issues/480))
#### 4.5.1
- Make `isLength()` / `isByteLength()` accept `{min, max}` as options object.
- ([#474](https://github.com/chriso/validator.js/issues/474))
+ ([#474](https://github.com/validatorjs/validator.js/issues/474))
#### 4.5.0
- Add validation for Indian mobile phone numbers
- ([#471](https://github.com/chriso/validator.js/pull/471))
+ ([#471](https://github.com/validatorjs/validator.js/pull/471))
- Tweak Greek and Chinese mobile phone validation
- ([#467](https://github.com/chriso/validator.js/pull/467),
- [#468](https://github.com/chriso/validator.js/pull/468))
+ ([#467](https://github.com/validatorjs/validator.js/pull/467),
+ [#468](https://github.com/validatorjs/validator.js/pull/468))
- Fixed a bug in `isDate()` when validating ISO 8601 dates without a timezone
- ([#472](https://github.com/chriso/validator.js/issues/472))
+ ([#472](https://github.com/validatorjs/validator.js/issues/472))
#### 4.4.1
- Allow triple hyphens in IDNA hostnames
- ([#466](https://github.com/chriso/validator.js/issues/466))
+ ([#466](https://github.com/validatorjs/validator.js/issues/466))
#### 4.4.0
- Added `isMACAddress()` validator
- ([#458](https://github.com/chriso/validator.js/pull/458))
+ ([#458](https://github.com/validatorjs/validator.js/pull/458))
- Added `isWhitelisted()` validator
- ([#462](https://github.com/chriso/validator.js/pull/462))
+ ([#462](https://github.com/validatorjs/validator.js/pull/462))
- Added a New Zealand locale to `isMobilePhone()`
- ([#452](https://github.com/chriso/validator.js/pull/452))
+ ([#452](https://github.com/validatorjs/validator.js/pull/452))
- Added options to control GMail address normalization
- ([#460](https://github.com/chriso/validator.js/pull/460))
+ ([#460](https://github.com/validatorjs/validator.js/pull/460))
#### 4.3.0
- Support Ember CLI module definitions
- ([#448](https://github.com/chriso/validator.js/pull/448))
+ ([#448](https://github.com/validatorjs/validator.js/pull/448))
- Added a Vietnam locale to `isMobilePhone()`
- ([#451](https://github.com/chriso/validator.js/pull/451))
+ ([#451](https://github.com/validatorjs/validator.js/pull/451))
#### 4.2.1
- Fix `isDate()` handling of RFC2822 timezones
- ([#447](https://github.com/chriso/validator.js/pull/447))
+ ([#447](https://github.com/validatorjs/validator.js/pull/447))
#### 4.2.0
- Fix `isDate()` handling of ISO8601 timezones
- ([#444](https://github.com/chriso/validator.js/pull/444))
+ ([#444](https://github.com/validatorjs/validator.js/pull/444))
- Fix the incorrect `isFloat('.') === true`
- ([#443](https://github.com/chriso/validator.js/pull/443))
+ ([#443](https://github.com/validatorjs/validator.js/pull/443))
- Added a Norwegian locale to `isMobilePhone()`
- ([#439](https://github.com/chriso/validator.js/pull/439))
+ ([#439](https://github.com/validatorjs/validator.js/pull/439))
#### 4.1.0
- General `isDate()` improvements
- ([#431](https://github.com/chriso/validator.js/pull/431))
+ ([#431](https://github.com/validatorjs/validator.js/pull/431))
- Tests now require node 4.0+
- ([#438](https://github.com/chriso/validator.js/pull/438))
+ ([#438](https://github.com/validatorjs/validator.js/pull/438))
#### 4.0.6
- Added a Taiwan locale to `isMobilePhone()`
- ([#432](https://github.com/chriso/validator.js/pull/432))
+ ([#432](https://github.com/validatorjs/validator.js/pull/432))
- Fixed a bug in `isBefore()` where it would return `null`
- ([#436](https://github.com/chriso/validator.js/pull/436))
+ ([#436](https://github.com/validatorjs/validator.js/pull/436))
#### 4.0.5
- Fixed a denial of service vulnerability in the `isEmail()` regex
- ([#152](https://github.com/chriso/validator.js/issues/152#issuecomment-131874928))
+ ([#152](https://github.com/validatorjs/validator.js/issues/152#issuecomment-131874928))
#### 4.0.4
- Reverted the leap year validation in `isDate()` as it introduced some regressions
- ([#422](https://github.com/chriso/validator.js/issues/422), [#423](https://github.com/chriso/validator.js/issues/423))
+ ([#422](https://github.com/validatorjs/validator.js/issues/422), [#423](https://github.com/validatorjs/validator.js/issues/423))
#### 4.0.3
- Added leap year validation to `isDate()`
- ([#418](https://github.com/chriso/validator.js/pull/418))
+ ([#418](https://github.com/validatorjs/validator.js/pull/418))
#### 4.0.2
- Fixed `isDecimal()` with an empty string
- ([#419](https://github.com/chriso/validator.js/issues/419))
+ ([#419](https://github.com/validatorjs/validator.js/issues/419))
#### 4.0.1
- Fixed `isByteLength()` with certain strings
- ([09f0c6d](https://github.com/chriso/validator.js/commit/09f0c6d2321f0c78af6a7de42e91b63955e4c01e))
+ ([09f0c6d](https://github.com/validatorjs/validator.js/commit/09f0c6d2321f0c78af6a7de42e91b63955e4c01e))
- Put length restrictions on email parts
- ([#258](https://github.com/chriso/validator.js/issues/258#issuecomment-127173612))
+ ([#258](https://github.com/validatorjs/validator.js/issues/258#issuecomment-127173612))
#### 4.0.0
- Simplified the `isEmail()` regex and fixed some edge cases
- ([#258](https://github.com/chriso/validator.js/issues/258#issuecomment-127173612))
+ ([#258](https://github.com/validatorjs/validator.js/issues/258#issuecomment-127173612))
- Added ISO 8601 date validation via `isISO8601()`
- ([#373](https://github.com/chriso/validator.js/issues/373))
+ ([#373](https://github.com/validatorjs/validator.js/issues/373))
diff --git a/README.md b/README.md
index fd00e458e..7dbed1295 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,12 @@
# validator.js
[![NPM version][npm-image]][npm-url]
-[](https://travis-ci.org/validatorjs/validator.js)
-[](https://codecov.io/gh/validatorjs/validator.js)
+[![CI][ci-image]][ci-url]
+[![Coverage][codecov-image]][codecov-url]
[![Downloads][downloads-image]][npm-url]
[](#backers)
[](#sponsors)
+[](https://gitter.im/validatorjs/community)
A library of string validators and sanitizers.
@@ -14,7 +15,7 @@ A library of string validators and sanitizers.
**This library validates and sanitizes strings only.**
If you're not sure if your input is a string, coerce it using `input + ''`.
-Passing anything other than a string is an error.
+Passing anything other than a string will result in an error.
## Installation and Usage
@@ -81,11 +82,11 @@ Here is a list of the validators currently available.
Validator | Description
--------------------------------------- | --------------------------------------
-**contains(str, seed [, options ])** | check if the string contains the seed.
`options` is an object that defaults to `{ ignoreCase: false}`.
`ignoreCase` specified whether the case of the substring be same or not.
+**contains(str, seed [, options ])** | check if the string contains the seed.
`options` is an object that defaults to `{ ignoreCase: false}`.
`ignoreCase` specified whether the case of the substring be same or not.
**equals(str, comparison)** | check if the string matches the comparison.
**isAfter(str [, date])** | check if the string is a date that's after the specified date (defaults to now).
**isAlpha(str [, locale, options])** | check if the string contains only letters (a-zA-Z).
Locale is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fa-IR', 'fr-CA', 'fr-FR', 'he', 'hu-HU', 'it-IT', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`) and defaults to `en-US`. Locale list is `validator.isAlphaLocales`. options is an optional object that can be supplied with the following key(s): ignore which can either be a String or RegExp of characters to be ignored e.g. " -" will ignore spaces and -'s.
-**isAlphanumeric(str [, locale])** | check if the string contains only letters and numbers.
Locale is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fa-IR', 'fr-CA', 'fr-FR', 'he', 'hu-HU', 'it-IT', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`) and defaults to `en-US`. Locale list is `validator.isAlphanumericLocales`.
+**isAlphanumeric(str [, locale, options])** | check if the string contains only letters and numbers (a-zA-Z0-9).
Locale is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fa-IR', 'fr-CA', 'fr-FR', 'he', 'hu-HU', 'it-IT', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`) and defaults to `en-US`. Locale list is `validator.isAlphanumericLocales`. options is an optional object that can be supplied with the following key(s): ignore which can either be a String or RegExp of characters to be ignored e.g. " -" will ignore spaces and -'s.
**isAscii(str)** | check if the string contains ASCII chars only.
**isBase32(str)** | check if a string is base32 encoded.
**isBase58(str)** | check if a string is base58 encoded.
@@ -102,7 +103,7 @@ Validator | Description
**isDecimal(str [, options])** | check if the string represents a decimal number, such as 0.1, .3, 1.1, 1.00003, 4.0, etc.
`options` is an object which defaults to `{force_decimal: false, decimal_digits: '1,', locale: 'en-US'}`
`locale` determine the decimal separator and is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fa', 'fa-AF', 'fa-IR', 'fr-FR', 'fr-CA', 'hu-HU', 'id-ID', 'it-IT', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pl-Pl', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA', 'vi-VN']`.
**Note:** `decimal_digits` is given as a range like '1,3', a specific value like '3' or min like '1,'.
**isDivisibleBy(str, number)** | check if the string is a number that's divisible by another.
**isEAN(str)** | check if the string is an EAN (European Article Number).
-**isEmail(str [, options])** | check if the string is an email.
`options` is an object which defaults to `{ allow_display_name: false, require_display_name: false, allow_utf8_local_part: true, require_tld: true, allow_ip_domain: false, domain_specific_validation: false, blacklisted_chars: '' }`. If `allow_display_name` is set to true, the validator will also match `Display Name `. If `require_display_name` is set to true, the validator will reject strings without the format `Display Name `. If `allow_utf8_local_part` is set to false, the validator will not allow any non-English UTF8 character in email address' local part. If `require_tld` is set to false, e-mail addresses without having TLD in their domain will also be matched. If `ignore_max_length` is set to true, the validator will not check for the standard max length of an email. If `allow_ip_domain` is set to true, the validator will allow IP addresses in the host part. If `domain_specific_validation` is true, some additional validation will be enabled, e.g. disallowing certain syntactically valid email addresses that are rejected by GMail. If `blacklisted_chars` recieves a string,then the validator will reject emails that include any of the characters in the string, in the name part.
+**isEmail(str [, options])** | check if the string is an email.
`options` is an object which defaults to `{ allow_display_name: false, require_display_name: false, allow_utf8_local_part: true, require_tld: true, allow_ip_domain: false, domain_specific_validation: false, blacklisted_chars: '' }`. If `allow_display_name` is set to true, the validator will also match `Display Name `. If `require_display_name` is set to true, the validator will reject strings without the format `Display Name `. If `allow_utf8_local_part` is set to false, the validator will not allow any non-English UTF8 character in email address' local part. If `require_tld` is set to false, e-mail addresses without having TLD in their domain will also be matched. If `ignore_max_length` is set to true, the validator will not check for the standard max length of an email. If `allow_ip_domain` is set to true, the validator will allow IP addresses in the host part. If `domain_specific_validation` is true, some additional validation will be enabled, e.g. disallowing certain syntactically valid email addresses that are rejected by GMail. If `blacklisted_chars` receives a string, then the validator will reject emails that include any of the characters in the string, in the name part.
**isEmpty(str [, options])** | check if the string has a length of zero.
`options` is an object which defaults to `{ ignore_whitespace:false }`.
**isEthereumAddress(str)** | check if the string is an [Ethereum](https://ethereum.org/) address using basic regex. Does not validate address checksums.
**isFloat(str [, options])** | check if the string is a float.
`options` is an object which can contain the keys `min`, `max`, `gt`, and/or `lt` to validate the float is within boundaries (e.g. `{ min: 7.22, max: 9.55 }`) it also has `locale` as an option.
`min` and `max` are equivalent to 'greater or equal' and 'less or equal', respectively while `gt` and `lt` are their strict counterparts.
`locale` determine the decimal separator and is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fr-CA', 'fr-FR', 'hu-HU', 'it-IT', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`. Locale list is `validator.isFloatLocales`.
@@ -114,12 +115,12 @@ Validator | Description
**isHexColor(str)** | check if the string is a hexadecimal color.
**isHSL(str)** | check if the string is an HSL (hue, saturation, lightness, optional alpha) color based on [CSS Colors Level 4 specification](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value).
Comma-separated format supported. Space-separated format supported with the exception of a few edge cases (ex: `hsl(200grad+.1%62%/1)`).
**isIBAN(str)** | check if a string is a IBAN (International Bank Account Number).
-**isIdentityCard(str [, locale])** | check if the string is a valid identity card code.
`locale` is one of `['ES', 'IN', 'IT', 'NO', 'zh-TW', 'he-IL', 'ar-TN', 'zh-CN']` OR `'any'`. If 'any' is used, function will check if any of the locals match.
Defaults to 'any'.
+**isIdentityCard(str [, locale])** | check if the string is a valid identity card code.
`locale` is one of `['ES', 'IN', 'IT', 'IR', 'MZ', 'NO', 'zh-TW', 'he-IL', 'ar-LY', 'ar-TN', 'zh-CN']` OR `'any'`. If 'any' is used, function will check if any of the locals match.
Defaults to 'any'.
**isIMEI(str [, options]))** | check if the string is a valid IMEI number. Imei should be of format `###############` or `##-######-######-#`.
`options` is an object which can contain the keys `allow_hyphens`. Defaults to first format . If allow_hyphens is set to true, the validator will validate the second format.
**isIn(str, values)** | check if the string is in a array of allowed values.
**isInt(str [, options])** | check if the string is an integer.
`options` is an object which can contain the keys `min` and/or `max` to check the integer is within boundaries (e.g. `{ min: 10, max: 99 }`). `options` can also contain the key `allow_leading_zeroes`, which when set to false will disallow integer values with leading zeroes (e.g. `{ allow_leading_zeroes: false }`). Finally, `options` can contain the keys `gt` and/or `lt` which will enforce integers being greater than or less than, respectively, the value provided (e.g. `{gt: 1, lt: 4}` for a number between 1 and 4).
**isIP(str [, version])** | check if the string is an IP (version 4 or 6).
-**isIPRange(str)** | check if the string is an IP Range(version 4 only).
+**isIPRange(str [, version])** | check if the string is an IP Range (version 4 or 6).
**isISBN(str [, version])** | check if the string is an ISBN (version 10 or 13).
**isISIN(str)** | check if the string is an [ISIN][ISIN] (stock/security identifier).
**isISO8601(str)** | check if the string is a valid [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date.
`options` is an object which defaults to `{ strict: false, strictSeparator: false }`. If `strict` is true, date strings with invalid dates like `2009-02-29` will be invalid. If `strictSeparator` is true, date strings with date and time separated by anything other than a T will be invalid.
@@ -129,22 +130,23 @@ Validator | Description
**isISSN(str [, options])** | check if the string is an [ISSN](https://en.wikipedia.org/wiki/International_Standard_Serial_Number).
`options` is an object which defaults to `{ case_sensitive: false, require_hyphen: false }`. If `case_sensitive` is true, ISSNs with a lowercase `'x'` as the check digit are rejected.
**isJSON(str [, options])** | check if the string is valid JSON (note: uses JSON.parse).
`options` is an object which defaults to `{ allow_primitives: false }`. If `allow_primitives` is true, the primitives 'true', 'false' and 'null' are accepted as valid JSON values.
**isJWT(str)** | check if the string is valid JWT token.
-**isLatLong(str [, options])** | check if the string is a valid latitude-longitude coordinate in the format `lat,long` or `lat, long`.
`options` is an object that defaults to `{ checkDMS: false }`. Pass `checkDMS` as `true` to validate DMS(degrees, minutes, and seconds) latitude-longitude format.
+**isLatLong(str [, options])** | check if the string is a valid latitude-longitude coordinate in the format `lat,long` or `lat, long`.
`options` is an object that defaults to `{ checkDMS: false }`. Pass `checkDMS` as `true` to validate DMS(degrees, minutes, and seconds) latitude-longitude format.
**isLength(str [, options])** | check if the string's length falls in a range.
`options` is an object which defaults to `{min:0, max: undefined}`. Note: this function takes into account surrogate pairs.
+**isLicensePlate(str [, locale])** | check if string matches the format of a country's license plate.
(locale is one of `['de-DE', 'de-LI', 'pt-PT', 'sq-AL', 'pt-BR'']` or `any`).
**isLocale(str)** | check if the string is a locale
**isLowercase(str)** | check if the string is lowercase.
-**isMACAddress(str)** | check if the string is a MAC address.
`options` is an object which defaults to `{no_colons: false}`. If `no_colons` is true, the validator will allow MAC addresses without the colons. Also, it allows the use of hyphens, spaces or dots e.g '01 02 03 04 05 ab', '01-02-03-04-05-ab' or '0102.0304.05ab'.
+**isMACAddress(str)** | check if the string is a MAC address.
`options` is an object which defaults to `{no_separators: false}`. If `no_separators` is true, the validator will allow MAC addresses without separators. Also, it allows the use of hyphens, spaces or dots e.g '01 02 03 04 05 ab', '01-02-03-04-05-ab' or '0102.0304.05ab'.
**isMagnetURI(str)** | check if the string is a [magnet uri format](https://en.wikipedia.org/wiki/Magnet_URI_scheme).
**isMD5(str)** | check if the string is a MD5 hash.
Please note that you can also use the `isHash(str, 'md5')` function. Keep in mind that MD5 has some collision weaknesses compared to other algorithms (e.g., SHA).
**isMimeType(str)** | check if the string matches to a valid [MIME type](https://en.wikipedia.org/wiki/Media_type) format
-**isMobilePhone(str [, locale [, options]])** | check if the string is a mobile phone number,
(locale is either an array of locales (e.g `['sk-SK', 'sr-RS']`) OR one of `['am-Am', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', ar-JO', 'ar-KW', 'ar-MA', 'ar-SA', 'ar-SY', 'ar-TN', 'az-AZ', 'az-LY', 'az-LB', 'bs-BA', 'be-BY', 'bg-BG', 'bn-BD', 'ca-AD', 'cs-CZ', 'da-DK', 'de-DE', 'de-AT', 'de-CH', 'de-LU', 'el-GR', 'en-AU', 'en-CA', 'en-GB', 'en-GG', 'en-GH', 'en-HK', 'en-MO', 'en-IE', 'en-IN', 'en-KE', 'en-MT', 'en-MU', 'en-NG', 'en-NZ', 'en-PK', 'en-PH', 'en-RW', 'en-SG', 'en-SL', 'en-UG', 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'en-ZW', 'es-AR', 'es-BO', 'es-CL', 'es-CO', 'es-CR', 'es-DO', 'es-HN', 'es-PE', 'es-EC', 'es-ES', 'es-MX', 'es-PA', 'es-PY', 'es-UY', 'et-EE', 'fa-IR', 'fi-FI', 'fj-FJ', 'fo-FO', 'fr-BE', 'fr-CA', 'fr-FR', 'fr-GF', 'fr-GP', 'fr-MQ', 'fr-RE', 'ga-IE', 'he-IL', 'hu-HU', 'id-ID', 'it-IT', 'it-SM', 'ja-JP', 'ka-GE', 'kk-KZ', 'kl-GL', 'ko-KR', 'lt-LT', 'ms-MY', 'nb-NO', 'ne-NP', 'nl-BE', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ro-RO', 'ru-RU', 'sl-SI', 'sk-SK', 'sq-AL', 'sr-RS', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA', 'uz-UZ', 'vi-VN', 'zh-CN', 'zh-HK', 'zh-MO', 'zh-TW']` OR defaults to 'any'. If 'any' or a falsey value is used, function will check if any of the locales match).
`options` is an optional object that can be supplied with the following keys: `strictMode`, if this is set to `true`, the mobile phone number must be supplied with the country code and therefore must start with `+`. Locale list is `validator.isMobilePhoneLocales`.
+**isMobilePhone(str [, locale [, options]])** | check if the string is a mobile phone number,
(locale is either an array of locales (e.g `['sk-SK', 'sr-RS']`) OR one of `['am-Am', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', ar-JO', 'ar-KW', 'ar-SA', 'ar-SY', 'ar-TN', 'az-AZ', 'az-LY', 'az-LB', 'bs-BA', 'be-BY', 'bg-BG', 'bn-BD', 'ca-AD', 'cs-CZ', 'da-DK', 'de-DE', 'de-AT', 'de-CH', 'de-LU', 'el-GR', 'en-AU', 'en-CA', 'en-GB', 'en-GG', 'en-GH', 'en-HK', 'en-MO', 'en-IE', 'en-IN', 'en-KE', 'en-MT', 'en-MU', 'en-NG', 'en-NZ', 'en-PK', 'en-PH', 'en-RW', 'en-SG', 'en-SL', 'en-UG', 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'en-ZW', 'es-AR', 'es-BO', 'es-CL', 'es-CO', 'es-CR', 'es-DO', 'es-HN', 'es-PE', 'es-EC', 'es-ES', 'es-MX', 'es-PA', 'es-PY', 'es-UY', 'et-EE', 'fa-IR', 'fi-FI', 'fj-FJ', 'fo-FO', 'fr-BE', 'fr-FR', 'fr-GF', 'fr-GP', 'fr-MQ', 'fr-RE', 'ga-IE', 'he-IL', 'hu-HU', 'id-ID', 'it-IT', 'it-SM', 'ja-JP', 'ka-GE', 'kk-KZ', 'kl-GL', 'ko-KR', 'lt-LT', 'ms-MY', ''mz-MZ', nb-NO', 'ne-NP', 'nl-BE', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'pt-AO', 'ro-RO', 'ru-RU', 'si-LK' 'sl-SI', 'sk-SK', 'sq-AL', 'sr-RS', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA', 'uz-UZ', 'vi-VN', 'zh-CN', 'zh-HK', 'zh-MO', 'zh-TW']` OR defaults to 'any'. If 'any' or a falsey value is used, function will check if any of the locales match).
`options` is an optional object that can be supplied with the following keys: `strictMode`, if this is set to `true`, the mobile phone number must be supplied with the country code and therefore must start with `+`. Locale list is `validator.isMobilePhoneLocales`.
**isMongoId(str)** | check if the string is a valid hex-encoded representation of a [MongoDB ObjectId][mongoid].
**isMultibyte(str)** | check if the string contains one or more multibyte chars.
**isNumeric(str [, options])** | check if the string contains only numbers.
`options` is an object which defaults to `{no_symbols: false}` it also has locale as an option. If `no_symbols` is true, the validator will reject numeric strings that feature a symbol (e.g. `+`, `-`, or `.`).
`locale` determine the decimal separator and is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fr-FR', 'fr-CA', 'hu-HU', 'it-IT', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`.
**isOctal(str)** | check if the string is a valid octal number.
-**isPassportNumber(str, countryCode)** | check if the string is a valid passport number.
(countryCode is one of `[ 'AM', 'AR', 'AT', 'AU', 'BE', 'BG', 'BY', 'CA', 'CH', 'CN', 'CY', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE' 'IN', 'IS', 'IT', 'JP', 'KR', 'LT', 'LU', 'LV', 'MT', 'NL', 'PO', 'PT', 'RO', 'RU', 'SE', 'SL', 'SK', 'TR', 'UA', 'US' ]`.
+**isPassportNumber(str, countryCode)** | check if the string is a valid passport number.
(countryCode is one of `[ 'AM', 'AR', 'AT', 'AU', 'BE', 'BG', 'BY', 'BR', 'CA', 'CH', 'CN', 'CY', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE' 'IN', 'IR', 'IS', 'IT', 'JP', 'KR', 'LT', 'LU', 'LV', 'LY', 'MT', 'MY', 'MZ', 'NL', 'PO', 'PT', 'RO', 'RU', 'SE', 'SL', 'SK', 'TR', 'UA', 'US' ]`.
**isPort(str)** | check if the string is a valid port number.
-**isPostalCode(str, locale)** | check if the string is a postal code,
(locale is one of `[ 'AD', 'AT', 'AU', 'AZ', 'BE', 'BG', 'BR', 'BY', 'CA', 'CH', 'CN', 'CZ', 'DE', 'DK', 'DO', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HT', 'HU', 'ID', 'IE' 'IL', 'IN', 'IR', 'IS', 'IT', 'JP', 'KE', 'LI', 'LT', 'LU', 'LV', 'MT', 'MX', 'MY', 'NL', 'NO', 'NP', 'NZ', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SG', 'SI', 'TH', 'TN', 'TW', 'UA', 'US', 'ZA', 'ZM' ]` OR 'any'. If 'any' is used, function will check if any of the locals match. Locale list is `validator.isPostalCodeLocales`.).
+**isPostalCode(str, locale)** | check if the string is a postal code,
(locale is one of `[ 'AD', 'AT', 'AU', 'AZ', 'BE', 'BG', 'BR', 'BY', 'CA', 'CH', 'CN', 'CZ', 'DE', 'DK', 'DO', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HT', 'HU', 'ID', 'IE' 'IL', 'IN', 'IR', 'IS', 'IT', 'JP', 'KE', 'KR', 'LI', 'LT', 'LU', 'LV', 'MT', 'MX', 'MY', 'NL', 'NO', 'NP', 'NZ', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SG', 'SI', 'TH', 'TN', 'TW', 'UA', 'US', 'ZA', 'ZM' ]` OR 'any'. If 'any' is used, function will check if any of the locals match. Locale list is `validator.isPostalCodeLocales`.).
**isRFC3339(str)** | check if the string is a valid [RFC 3339](https://tools.ietf.org/html/rfc3339) date.
**isRgbColor(str [, includePercentValues])** | check if the string is a rgb or rgba color.
`includePercentValues` defaults to `true`. If you don't want to allow to set `rgb` or `rgba` values with percents, like `rgb(5%,5%,5%)`, or `rgba(90%,90%,90%,.3)`, then set it to false.
**isSemVer(str)** | check if the string is a Semantic Versioning Specification (SemVer).
@@ -152,11 +154,11 @@ Validator | Description
**isUppercase(str)** | check if the string is uppercase.
**isSlug** | Check if the string is of type slug. `Options` allow a single hyphen between string. e.g. [`cn-cn`, `cn-c-c`]
**isStrongPassword(str [, options])** | Check if a password is strong or not. Allows for custom requirements or scoring rules. If `returnScore` is true, then the function returns an integer score for the password rather than a boolean.
Default options:
`{ minLength: 8, minLowercase: 1, minUppercase: 1, minNumbers: 1, minSymbols: 1, returnScore: false, pointsPerUnique: 1, pointsPerRepeat: 0.5, pointsForContainingLower: 10, pointsForContainingUpper: 10, pointsForContainingNumber: 10, pointsForContainingSymbol: 10 }`
-**isTaxID(str, locale)** | Check if the given value is a valid Tax Identification Number. Default locale is `en-US`.
More info about exact TIN support can be found in `src/lib/isTaxID.js`
Supported locales: `[ 'bg-BG', 'cs-CZ', 'de-AT', 'de-DE', 'dk-DK', 'el-CY', 'el-GR', 'en-GB', 'en-IE', 'en-US', 'es-ES', 'et-EE', 'fi-FI', 'fr-BE', 'fr-FR', 'fr-LU', 'hr-HR', 'hu-HU', 'it-IT', 'lb-LU', 'lt-LT', 'lv-LV' 'mt-MT', 'nl-BE', 'nl-NL', 'pl-PL', 'pt-PT', 'ro-RO', 'sk-SK', 'sl-SI', 'sv-SE' ]`
-**isURL(str [, options])** | check if the string is an URL.
`options` is an object which defaults to `{ protocols: ['http','https','ftp'], require_tld: true, require_protocol: false, require_host: true, require_valid_protocol: true, allow_underscores: false, host_whitelist: false, host_blacklist: false, allow_trailing_dot: false, allow_protocol_relative_urls: false, disallow_auth: false }`.
require_protocol - if set as true isURL will return false if protocol is not present in the URL.
require_valid_protocol - isURL will check if the URL's protocol is present in the protocols option.
protocols - valid protocols can be modified with this option.
require_host - if set as false isURL will not check if host is present in the URL.
require_port - if set as true isURL will check if port is present in the URL.
allow_protocol_relative_urls - if set as true protocol relative URLs will be allowed.
validate_length - if set as false isURL will skip string length validation (2083 characters is IE max URL length).
+**isTaxID(str, locale)** | Check if the given value is a valid Tax Identification Number. Default locale is `en-US`.
More info about exact TIN support can be found in `src/lib/isTaxID.js`
Supported locales: `[ 'bg-BG', 'cs-CZ', 'de-AT', 'de-DE', 'dk-DK', 'el-CY', 'el-GR', 'en-GB', 'en-IE', 'en-US', 'es-ES', 'et-EE', 'fi-FI', 'fr-BE', 'fr-FR', 'fr-LU', 'hr-HR', 'hu-HU', 'it-IT', 'lb-LU', 'lt-LT', 'lv-LV' 'mt-MT', 'nl-BE', 'nl-NL', 'pl-PL', 'pt-BR', 'pt-PT', 'ro-RO', 'sk-SK', 'sl-SI', 'sv-SE' ]`
+**isURL(str [, options])** | check if the string is an URL.
`options` is an object which defaults to `{ protocols: ['http','https','ftp'], require_tld: true, require_protocol: false, require_host: true, require_port: false, require_valid_protocol: true, allow_underscores: false, host_whitelist: false, host_blacklist: false, allow_trailing_dot: false, allow_protocol_relative_urls: false, disallow_auth: false, validate_length: true }`.
require_protocol - if set as true isURL will return false if protocol is not present in the URL.
require_valid_protocol - isURL will check if the URL's protocol is present in the protocols option.
protocols - valid protocols can be modified with this option.
require_host - if set as false isURL will not check if host is present in the URL.
require_port - if set as true isURL will check if port is present in the URL.
allow_protocol_relative_urls - if set as true protocol relative URLs will be allowed.
validate_length - if set as false isURL will skip string length validation (2083 characters is IE max URL length).
**isUUID(str [, version])** | check if the string is a UUID (version 3, 4 or 5).
**isVariableWidth(str)** | check if the string contains a mixture of full and half-width chars.
-**isVAT(str, countryCode)** | checks that the string is a [valid VAT number](https://en.wikipedia.org/wiki/VAT_identification_number) if validation is available for the given country code matching [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
Available country codes: `[ 'GB' ]`.
+**isVAT(str, countryCode)** | checks that the string is a [valid VAT number](https://en.wikipedia.org/wiki/VAT_identification_number) if validation is available for the given country code matching [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
Available country codes: `[ 'GB', 'IT' ]`.
**isWhitelisted(str, chars)** | checks characters if they appear in the whitelist.
**matches(str, pattern [, modifiers])** | check if string matches the pattern.
Either `matches('foo', /foo/i)` or `matches('foo', 'foo', 'i')`.
@@ -182,7 +184,7 @@ Sanitizer | Description
### XSS Sanitization
-XSS sanitization was removed from the library in [2d5d6999](https://github.com/chriso/validator.js/commit/2d5d6999541add350fb396ef02dc42ca3215049e).
+XSS sanitization was removed from the library in [2d5d6999](https://github.com/validatorjs/validator.js/commit/2d5d6999541add350fb396ef02dc42ca3215049e).
For an alternative, have a look at Yahoo's [xss-filters library](https://github.com/yahoo/xss-filters) or at [DOMPurify](https://github.com/cure53/DOMPurify).
@@ -252,8 +254,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[npm-url]: https://npmjs.org/package/validator
[npm-image]: http://img.shields.io/npm/v/validator.svg
-[travis-url]: https://travis-ci.org/chriso/validator.js
-[travis-image]: http://img.shields.io/travis/chriso/validator.js.svg
+[codecov-url]: https://codecov.io/gh/validatorjs/validator.js
+[codecov-image]: https://codecov.io/gh/validatorjs/validator.js/branch/master/graph/badge.svg
+
+[ci-url]: https://github.com/validatorjs/validator.js/actions?query=workflow%3ACI
+[ci-image]: https://github.com/validatorjs/validator.js/workflows/CI/badge.svg?branch=master
[amd]: http://requirejs.org/docs/whyamd.html
[bower]: http://bower.io/
diff --git a/bower.json b/bower.json
index fb98d0ebc..427670cfc 100644
--- a/bower.json
+++ b/bower.json
@@ -1,7 +1,7 @@
{
"name": "validator-js",
"main": "validator.js",
- "homepage": "https://github.com/chriso/validator.js",
+ "homepage": "https://github.com/validatorjs/validator.js",
"authors": [
"Chris O'Hara "
],
diff --git a/package.json b/package.json
index 1257ac33d..72573e375 100644
--- a/package.json
+++ b/package.json
@@ -1,9 +1,9 @@
{
"name": "validator",
"description": "String validation and sanitization",
- "version": "13.5.0",
+ "version": "13.6.0",
"sideEffects": false,
- "homepage": "https://github.com/chriso/validator.js",
+ "homepage": "https://github.com/validatorjs/validator.js",
"files": [
"index.js",
"es",
@@ -25,18 +25,15 @@
],
"author": "Chris O'Hara ",
"contributors": [
- {
- "name": "Anthony Nandaa",
- "url": "https://github.com/profnandaa"
- }
+ "Anthony Nandaa (https://github.com/profnandaa)"
],
"main": "index.js",
"bugs": {
- "url": "https://github.com/chriso/validator.js/issues"
+ "url": "https://github.com/validatorjs/validator.js/issues"
},
"repository": {
"type": "git",
- "url": "https://github.com/chriso/validator.js.git"
+ "url": "git+https://github.com/validatorjs/validator.js.git"
},
"devDependencies": {
"@babel/cli": "^7.0.0",
@@ -48,7 +45,7 @@
"eslint": "^4.19.1",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-import": "^2.11.0",
- "mocha": "^5.1.1",
+ "mocha": "^6.2.3",
"nyc": "^14.1.0",
"rimraf": "^3.0.0",
"rollup": "^0.43.0",
diff --git a/src/index.js b/src/index.js
index 41d287053..675947481 100644
--- a/src/index.js
+++ b/src/index.js
@@ -115,11 +115,12 @@ import isWhitelisted from './lib/isWhitelisted';
import normalizeEmail from './lib/normalizeEmail';
import isSlug from './lib/isSlug';
+import isLicensePlate from './lib/isLicensePlate';
import isStrongPassword from './lib/isStrongPassword';
import isVAT from './lib/isVAT';
-const version = '13.5.0';
+const version = '13.6.0';
const validator = {
version,
@@ -219,6 +220,7 @@ const validator = {
isStrongPassword,
isTaxID,
isDate,
+ isLicensePlate,
isVAT,
};
diff --git a/src/lib/isAlphanumeric.js b/src/lib/isAlphanumeric.js
index 1b2481cea..b259ab908 100644
--- a/src/lib/isAlphanumeric.js
+++ b/src/lib/isAlphanumeric.js
@@ -1,8 +1,22 @@
import assertString from './util/assertString';
import { alphanumeric } from './alpha';
-export default function isAlphanumeric(str, locale = 'en-US') {
- assertString(str);
+export default function isAlphanumeric(_str, locale = 'en-US', options = {}) {
+ assertString(_str);
+
+ let str = _str;
+ const { ignore } = options;
+
+ if (ignore) {
+ if (ignore instanceof RegExp) {
+ str = str.replace(ignore, '');
+ } else if (typeof ignore === 'string') {
+ str = str.replace(new RegExp(`[${ignore.replace(/[-[\]{}()*+?.,\\^$|#\\s]/g, '\\$&')}]`, 'g'), ''); // escape regex for ignore
+ } else {
+ throw new Error('ignore should be instance of a String or RegExp');
+ }
+ }
+
if (locale in alphanumeric) {
return alphanumeric[locale].test(str);
}
diff --git a/src/lib/isBIC.js b/src/lib/isBIC.js
index 1420da69a..240bfe18b 100644
--- a/src/lib/isBIC.js
+++ b/src/lib/isBIC.js
@@ -1,8 +1,17 @@
import assertString from './util/assertString';
+import { CountryCodes } from './isISO31661Alpha2';
-const isBICReg = /^[A-z]{4}[A-z]{2}\w{2}(\w{3})?$/;
+// https://en.wikipedia.org/wiki/ISO_9362
+const isBICReg = /^[A-Za-z]{6}[A-Za-z0-9]{2}([A-Za-z0-9]{3})?$/;
export default function isBIC(str) {
assertString(str);
+
+ // toUpperCase() should be removed when a new major version goes out that changes
+ // the regex to [A-Z] (per the spec).
+ if (CountryCodes.indexOf(str.slice(4, 6).toUpperCase()) < 0) {
+ return false;
+ }
+
return isBICReg.test(str);
}
diff --git a/src/lib/isBtcAddress.js b/src/lib/isBtcAddress.js
index 0c50142a2..2dfd04651 100644
--- a/src/lib/isBtcAddress.js
+++ b/src/lib/isBtcAddress.js
@@ -1,9 +1,14 @@
import assertString from './util/assertString';
// supports Bech32 addresses
-const btc = /^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,39}$/;
+const bech32 = /^(bc1)[a-z0-9]{25,39}$/;
+const base58 = /^(1|3)[A-HJ-NP-Za-km-z1-9]{25,39}$/;
export default function isBtcAddress(str) {
assertString(str);
- return btc.test(str);
+ // check for bech32
+ if (str.startsWith('bc1')) {
+ return bech32.test(str);
+ }
+ return base58.test(str);
}
diff --git a/src/lib/isDataURI.js b/src/lib/isDataURI.js
index 2df26decb..01e43f70c 100644
--- a/src/lib/isDataURI.js
+++ b/src/lib/isDataURI.js
@@ -22,9 +22,10 @@ export default function isDataURI(str) {
return false;
}
for (let i = 0; i < attributes.length; i++) {
- if (i === attributes.length - 1 && attributes[i].toLowerCase() === 'base64') {
- // ok
- } else if (!validAttribute.test(attributes[i])) {
+ if (
+ !(i === attributes.length - 1 && attributes[i].toLowerCase() === 'base64') &&
+ !validAttribute.test(attributes[i])
+ ) {
return false;
}
}
diff --git a/src/lib/isEAN.js b/src/lib/isEAN.js
index 674e14ceb..968c385dd 100644
--- a/src/lib/isEAN.js
+++ b/src/lib/isEAN.js
@@ -3,20 +3,25 @@
* the thirteen-digit EAN-13, while the
* less commonly used 8-digit EAN-8 barcode was
* introduced for use on small packages.
+ * Also EAN/UCC-14 is used for Grouping of individual
+ * trade items above unit level(Intermediate, Carton or Pallet).
+ * For more info about EAN-14 checkout: https://www.gtin.info/itf-14-barcodes/
* EAN consists of:
* GS1 prefix, manufacturer code, product code and check digit
* Reference: https://en.wikipedia.org/wiki/International_Article_Number
+ * Reference: https://www.gtin.info/
*/
import assertString from './util/assertString';
/**
- * Define EAN Lenghts; 8 for EAN-8; 13 for EAN-13
- * and Regular Expression for valid EANs (EAN-8, EAN-13),
- * with exact numberic matching of 8 or 13 digits [0-9]
+ * Define EAN Lenghts; 8 for EAN-8; 13 for EAN-13; 14 for EAN-14
+ * and Regular Expression for valid EANs (EAN-8, EAN-13, EAN-14),
+ * with exact numberic matching of 8 or 13 or 14 digits [0-9]
*/
const LENGTH_EAN_8 = 8;
-const validEanRegex = /^(\d{8}|\d{13})$/;
+const LENGTH_EAN_14 = 14;
+const validEanRegex = /^(\d{8}|\d{13}|\d{14})$/;
/**
@@ -28,7 +33,7 @@ const validEanRegex = /^(\d{8}|\d{13})$/;
* @return {number}
*/
function getPositionWeightThroughLengthAndIndex(length, index) {
- if (length === LENGTH_EAN_8) {
+ if (length === LENGTH_EAN_8 || length === LENGTH_EAN_14) {
return (index % 2 === 0) ? 3 : 1;
}
@@ -56,7 +61,7 @@ function calculateCheckDigit(ean) {
/**
* Check if string is valid EAN:
- * Matches EAN-8/EAN-13 regex
+ * Matches EAN-8/EAN-13/EAN-14 regex
* Has valid check digit.
*
* @param {string} str
diff --git a/src/lib/isEmail.js b/src/lib/isEmail.js
index b570cb254..ecbd398c9 100644
--- a/src/lib/isEmail.js
+++ b/src/lib/isEmail.js
@@ -16,7 +16,7 @@ const default_email_options = {
/* eslint-disable max-len */
/* eslint-disable no-control-regex */
-const splitNameAddress = /^([^\x00-\x1F\x7F-\x9F\cX]+)<(.+)>$/i;
+const splitNameAddress = /^([^\x00-\x1F\x7F-\x9F\cX]+)$)/g, '');
+
// sometimes need to trim the last space to get the display name
// because there may be a space between display name and email address
// eg. myname
diff --git a/src/lib/isFQDN.js b/src/lib/isFQDN.js
index e58c7503d..3dff7d2fd 100644
--- a/src/lib/isFQDN.js
+++ b/src/lib/isFQDN.js
@@ -17,39 +17,52 @@ export default function isFQDN(str, options) {
str = str.substring(0, str.length - 1);
}
const parts = str.split('.');
- for (let i = 0; i < parts.length; i++) {
- if (parts[i].length > 63) {
+ const tld = parts[parts.length - 1];
+
+ if (options.require_tld) {
+ // disallow fqdns without tld
+ if (parts.length < 2) {
return false;
}
- }
- if (options.require_tld) {
- const tld = parts.pop();
- if (!parts.length || !/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
+
+ if (!/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
return false;
}
+
// disallow spaces && special characers
if (/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20\u00A9\uFFFD]/.test(tld)) {
return false;
}
}
- for (let part, i = 0; i < parts.length; i++) {
- part = parts[i];
- if (!options.allow_numeric_tld && i === parts.length - 1 && /^\d+$/.test(part)) {
- return false; // reject numeric TLDs
+
+ // reject numeric TLDs
+ if (!options.allow_numeric_tld && /^\d+$/.test(tld)) {
+ return false;
+ }
+
+ return parts.every((part) => {
+ if (part.length > 63) {
+ return false;
}
+
if (!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(part)) {
return false;
}
+
// disallow full-width chars
if (/[\uff01-\uff5e]/.test(part)) {
return false;
}
- if (part[0] === '-' || part[part.length - 1] === '-') {
+
+ // disallow parts starting or ending with hyphen
+ if (/^-|-$/.test(part)) {
return false;
}
+
if (!options.allow_underscores && /_/.test(part)) {
return false;
}
- }
- return true;
+
+ return true;
+ });
}
diff --git a/src/lib/isHSL.js b/src/lib/isHSL.js
index b4f446334..05cb43962 100644
--- a/src/lib/isHSL.js
+++ b/src/lib/isHSL.js
@@ -1,10 +1,19 @@
import assertString from './util/assertString';
-const hslcomma = /^(hsl)a?\(\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?))(deg|grad|rad|turn|\s*)(\s*,\s*(\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%){2}\s*(,\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%?)\s*)?\)$/i;
-const hslspace = /^(hsl)a?\(\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?))(deg|grad|rad|turn|\s)(\s*(\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%){2}\s*(\/\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%?)\s*)?\)$/i;
+const hslComma = /^hsla?\(((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?))(deg|grad|rad|turn)?(,(\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%){2}(,((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%?))?\)$/i;
+const hslSpace = /^hsla?\(((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?))(deg|grad|rad|turn)?(\s(\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%){2}\s?(\/\s((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%?)\s?)?\)$/i;
+
export default function isHSL(str) {
assertString(str);
- return hslcomma.test(str) || hslspace.test(str);
+
+ // Strip duplicate spaces before calling the validation regex (See #1598 for more info)
+ const strippedStr = str.replace(/\s+/g, ' ').replace(/\s?(hsla?\(|\)|,)\s?/ig, '$1');
+
+ if (strippedStr.indexOf(',') !== -1) {
+ return hslComma.test(strippedStr);
+ }
+
+ return hslSpace.test(strippedStr);
}
diff --git a/src/lib/isIBAN.js b/src/lib/isIBAN.js
index 77050f1ed..19853aaf2 100644
--- a/src/lib/isIBAN.js
+++ b/src/lib/isIBAN.js
@@ -60,6 +60,7 @@ const ibanRegexThroughCountryCode = {
MR: /^(MR[0-9]{2})\d{23}$/,
MT: /^(MT[0-9]{2})[A-Z]{4}\d{5}[A-Z0-9]{18}$/,
MU: /^(MU[0-9]{2})[A-Z]{4}\d{19}[A-Z]{3}$/,
+ MZ: /^(MZ[0-9]{2})\d{21}$/,
NL: /^(NL[0-9]{2})[A-Z]{4}\d{10}$/,
NO: /^(NO[0-9]{2})\d{11}$/,
PK: /^(PK[0-9]{2})[A-Z0-9]{4}\d{16}$/,
diff --git a/src/lib/isIP.js b/src/lib/isIP.js
index a9a805781..25856cae0 100644
--- a/src/lib/isIP.js
+++ b/src/lib/isIP.js
@@ -28,86 +28,37 @@ import assertString from './util/assertString';
where the interface "ne0" belongs to the 1st link, "pvc1.3" belongs
to the 5th link, and "interface10" belongs to the 10th organization.
* * */
-const ipv4Maybe = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/;
-const ipv6Block = /^[0-9A-F]{1,4}$/i;
+const IPv4SegmentFormat = '(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])';
+const IPv4AddressFormat = `(${IPv4SegmentFormat}[.]){3}${IPv4SegmentFormat}`;
+const IPv4AddressRegExp = new RegExp(`^${IPv4AddressFormat}$`);
+
+const IPv6SegmentFormat = '(?:[0-9a-fA-F]{1,4})';
+const IPv6AddressRegExp = new RegExp('^(' +
+ `(?:${IPv6SegmentFormat}:){7}(?:${IPv6SegmentFormat}|:)|` +
+ `(?:${IPv6SegmentFormat}:){6}(?:${IPv4AddressFormat}|:${IPv6SegmentFormat}|:)|` +
+ `(?:${IPv6SegmentFormat}:){5}(?::${IPv4AddressFormat}|(:${IPv6SegmentFormat}){1,2}|:)|` +
+ `(?:${IPv6SegmentFormat}:){4}(?:(:${IPv6SegmentFormat}){0,1}:${IPv4AddressFormat}|(:${IPv6SegmentFormat}){1,3}|:)|` +
+ `(?:${IPv6SegmentFormat}:){3}(?:(:${IPv6SegmentFormat}){0,2}:${IPv4AddressFormat}|(:${IPv6SegmentFormat}){1,4}|:)|` +
+ `(?:${IPv6SegmentFormat}:){2}(?:(:${IPv6SegmentFormat}){0,3}:${IPv4AddressFormat}|(:${IPv6SegmentFormat}){1,5}|:)|` +
+ `(?:${IPv6SegmentFormat}:){1}(?:(:${IPv6SegmentFormat}){0,4}:${IPv4AddressFormat}|(:${IPv6SegmentFormat}){1,6}|:)|` +
+ `(?::((?::${IPv6SegmentFormat}){0,5}:${IPv4AddressFormat}|(?::${IPv6SegmentFormat}){1,7}|:))` +
+ ')(%[0-9a-zA-Z-.:]{1,})?$');
export default function isIP(str, version = '') {
assertString(str);
version = String(version);
if (!version) {
return isIP(str, 4) || isIP(str, 6);
- } else if (version === '4') {
- if (!ipv4Maybe.test(str)) {
+ }
+ if (version === '4') {
+ if (!IPv4AddressRegExp.test(str)) {
return false;
}
const parts = str.split('.').sort((a, b) => a - b);
return parts[3] <= 255;
- } else if (version === '6') {
- let addressAndZone = [str];
- // ipv6 addresses could have scoped architecture
- // according to https://tools.ietf.org/html/rfc4007#section-11
- if (str.includes('%')) {
- addressAndZone = str.split('%');
- if (addressAndZone.length !== 2) {
- // it must be just two parts
- return false;
- }
- if (!addressAndZone[0].includes(':')) {
- // the first part must be the address
- return false;
- }
-
- if (addressAndZone[1] === '') {
- // the second part must not be empty
- return false;
- }
- }
-
- const blocks = addressAndZone[0].split(':');
- let foundOmissionBlock = false; // marker to indicate ::
-
- // At least some OS accept the last 32 bits of an IPv6 address
- // (i.e. 2 of the blocks) in IPv4 notation, and RFC 3493 says
- // that '::ffff:a.b.c.d' is valid for IPv4-mapped IPv6 addresses,
- // and '::a.b.c.d' is deprecated, but also valid.
- const foundIPv4TransitionBlock = isIP(blocks[blocks.length - 1], 4);
- const expectedNumberOfBlocks = foundIPv4TransitionBlock ? 7 : 8;
-
- if (blocks.length > expectedNumberOfBlocks) {
- return false;
- }
- // initial or final ::
- if (str === '::') {
- return true;
- } else if (str.substr(0, 2) === '::') {
- blocks.shift();
- blocks.shift();
- foundOmissionBlock = true;
- } else if (str.substr(str.length - 2) === '::') {
- blocks.pop();
- blocks.pop();
- foundOmissionBlock = true;
- }
-
- for (let i = 0; i < blocks.length; ++i) {
- // test for a :: which can not be at the string start/end
- // since those cases have been handled above
- if (blocks[i] === '' && i > 0 && i < blocks.length - 1) {
- if (foundOmissionBlock) {
- return false; // multiple :: in address
- }
- foundOmissionBlock = true;
- } else if (foundIPv4TransitionBlock && i === blocks.length - 1) {
- // it has been checked before that the last
- // block is a valid IPv4 address
- } else if (!ipv6Block.test(blocks[i])) {
- return false;
- }
- }
- if (foundOmissionBlock) {
- return blocks.length >= 1;
- }
- return blocks.length === expectedNumberOfBlocks;
+ }
+ if (version === '6') {
+ return !!IPv6AddressRegExp.test(str);
}
return false;
}
diff --git a/src/lib/isIPRange.js b/src/lib/isIPRange.js
index ffb4e1afa..5bb6916c5 100644
--- a/src/lib/isIPRange.js
+++ b/src/lib/isIPRange.js
@@ -1,9 +1,11 @@
import assertString from './util/assertString';
import isIP from './isIP';
-const subnetMaybe = /^\d{1,2}$/;
+const subnetMaybe = /^\d{1,3}$/;
+const v4Subnet = 32;
+const v6Subnet = 128;
-export default function isIPRange(str) {
+export default function isIPRange(str, version = '') {
assertString(str);
const parts = str.split('/');
@@ -21,5 +23,25 @@ export default function isIPRange(str) {
return false;
}
- return isIP(parts[0], 4) && parts[1] <= 32 && parts[1] >= 0;
+ const isValidIP = isIP(parts[0], version);
+ if (!isValidIP) {
+ return false;
+ }
+
+ // Define valid subnet according to IP's version
+ let expectedSubnet = null;
+ switch (String(version)) {
+ case '4':
+ expectedSubnet = v4Subnet;
+ break;
+
+ case '6':
+ expectedSubnet = v6Subnet;
+ break;
+
+ default:
+ expectedSubnet = isIP(parts[0], '6') ? v6Subnet : v4Subnet;
+ }
+
+ return parts[1] <= expectedSubnet && parts[1] >= 0;
}
diff --git a/src/lib/isISIN.js b/src/lib/isISIN.js
index 4576b684c..a6f6fa645 100644
--- a/src/lib/isISIN.js
+++ b/src/lib/isISIN.js
@@ -2,6 +2,12 @@ import assertString from './util/assertString';
const isin = /^[A-Z]{2}[0-9A-Z]{9}[0-9]$/;
+// this link details how the check digit is calculated:
+// https://www.isin.org/isin-format/. it is a little bit
+// odd in that it works with digits, not numbers. in order
+// to make only one pass through the ISIN characters, the
+// each alpha character is handled as 2 characters within
+// the loop.
export default function isISIN(str) {
assertString(str);
@@ -9,27 +15,44 @@ export default function isISIN(str) {
return false;
}
- const checksumStr = str.replace(/[A-Z]/g, character => (parseInt(character, 36)));
-
+ let double = true;
let sum = 0;
- let digit;
- let tmpNum;
- let shouldDouble = true;
- for (let i = checksumStr.length - 2; i >= 0; i--) {
- digit = checksumStr.substring(i, (i + 1));
- tmpNum = parseInt(digit, 10);
- if (shouldDouble) {
- tmpNum *= 2;
- if (tmpNum >= 10) {
- sum += tmpNum + 1;
- } else {
- sum += tmpNum;
+ // convert values
+ for (let i = str.length - 2; i >= 0; i--) {
+ if (str[i] >= 'A' && str[i] <= 'Z') {
+ const value = str[i].charCodeAt(0) - 55;
+ const lo = value % 10;
+ const hi = Math.trunc(value / 10);
+ // letters have two digits, so handle the low order
+ // and high order digits separately.
+ for (const digit of [lo, hi]) {
+ if (double) {
+ if (digit >= 5) {
+ sum += 1 + ((digit - 5) * 2);
+ } else {
+ sum += digit * 2;
+ }
+ } else {
+ sum += digit;
+ }
+ double = !double;
}
} else {
- sum += tmpNum;
+ const digit = str[i].charCodeAt(0) - '0'.charCodeAt(0);
+ if (double) {
+ if (digit >= 5) {
+ sum += 1 + ((digit - 5) * 2);
+ } else {
+ sum += digit * 2;
+ }
+ } else {
+ sum += digit;
+ }
+ double = !double;
}
- shouldDouble = !shouldDouble;
}
- return parseInt(str.substr(str.length - 1), 10) === (10000 - sum) % 10;
+ const check = (Math.trunc(((sum + 9) / 10)) * 10) - sum;
+
+ return +str[str.length - 1] === check;
}
diff --git a/src/lib/isISO31661Alpha2.js b/src/lib/isISO31661Alpha2.js
index ee1c33a40..e91ae8717 100644
--- a/src/lib/isISO31661Alpha2.js
+++ b/src/lib/isISO31661Alpha2.js
@@ -1,5 +1,4 @@
import assertString from './util/assertString';
-import includes from './util/includes';
// from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
const validISO31661Alpha2CountriesCodes = [
@@ -32,5 +31,7 @@ const validISO31661Alpha2CountriesCodes = [
export default function isISO31661Alpha2(str) {
assertString(str);
- return includes(validISO31661Alpha2CountriesCodes, str.toUpperCase());
+ return validISO31661Alpha2CountriesCodes.indexOf(str.toUpperCase()) >= 0;
}
+
+export const CountryCodes = validISO31661Alpha2CountriesCodes;
diff --git a/src/lib/isIdentityCard.js b/src/lib/isIdentityCard.js
index 24f828ae8..872ff1920 100644
--- a/src/lib/isIdentityCard.js
+++ b/src/lib/isIdentityCard.js
@@ -75,6 +75,25 @@ const validators = {
return c === 0;
},
+ IR: (str) => {
+ if (!str.match(/^\d{10}$/)) return false;
+ str = (`0000${str}`).substr(str.length - 6);
+
+ if (parseInt(str.substr(3, 6), 10) === 0) return false;
+
+ const lastNumber = parseInt(str.substr(9, 1), 10);
+ let sum = 0;
+
+ for (let i = 0; i < 9; i++) {
+ sum += parseInt(str.substr(i, 1), 10) * (10 - i);
+ }
+
+ sum %= 11;
+
+ return (
+ (sum < 2 && lastNumber === sum) || (sum >= 2 && lastNumber === 11 - sum)
+ );
+ },
IT: function IT(str) {
if (str.length !== 9) return false;
if (str === 'CA00000AA') return false; // https://it.wikipedia.org/wiki/Carta_d%27identit%C3%A0_elettronica_italiana
@@ -119,6 +138,19 @@ const validators = {
}
return sum % 10 === 0;
},
+ 'ar-LY': (str) => {
+ // Libya National Identity Number NIN is 12 digits, the first digit is either 1 or 2
+ const NIN = /^(1|2)\d{11}$/;
+
+ // sanitize user input
+ const sanitized = str.trim();
+
+ // validate the data structure
+ if (!NIN.test(sanitized)) {
+ return false;
+ }
+ return true;
+ },
'ar-TN': (str) => {
const DNI = /^\d{8}$/;
diff --git a/src/lib/isLicensePlate.js b/src/lib/isLicensePlate.js
new file mode 100644
index 000000000..a28d66da8
--- /dev/null
+++ b/src/lib/isLicensePlate.js
@@ -0,0 +1,30 @@
+import assertString from './util/assertString';
+
+const validators = {
+ 'de-DE': str =>
+ /^((AW|UL|AK|GA|AÖ|LF|AZ|AM|AS|ZE|AN|AB|A|KG|KH|BA|EW|BZ|HY|KM|BT|HP|B|BC|BI|BO|FN|TT|ÜB|BN|AH|BS|FR|HB|ZZ|BB|BK|BÖ|OC|OK|CW|CE|C|CO|LH|CB|KW|LC|LN|DA|DI|DE|DH|SY|NÖ|DO|DD|DU|DN|D|EI|EA|EE|FI|EM|EL|EN|PF|ED|EF|ER|AU|ZP|E|ES|NT|EU|FL|FO|FT|FF|F|FS|FD|FÜ|GE|G|GI|GF|GS|ZR|GG|GP|GR|NY|ZI|GÖ|GZ|GT|HA|HH|HM|HU|WL|HZ|WR|RN|HK|HD|HN|HS|GK|HE|HF|RZ|HI|HG|HO|HX|IK|IL|IN|J|JL|KL|KA|KS|KF|KE|KI|KT|KO|KN|KR|KC|KU|K|LD|LL|LA|L|OP|LM|LI|LB|LU|LÖ|HL|LG|MD|GN|MZ|MA|ML|MR|MY|AT|DM|MC|NZ|RM|RG|MM|ME|MB|MI|FG|DL|HC|MW|RL|MK|MG|MÜ|WS|MH|M|MS|NU|NB|ND|NM|NK|NW|NR|NI|NF|DZ|EB|OZ|TG|TO|N|OA|GM|OB|CA|EH|FW|OF|OL|OE|OG|BH|LR|OS|AA|GD|OH|KY|NP|WK|PB|PA|PE|PI|PS|P|PM|PR|RA|RV|RE|R|H|SB|WN|RS|RD|RT|BM|NE|GV|RP|SU|GL|RO|GÜ|RH|EG|RW|PN|SK|MQ|RU|SZ|RI|SL|SM|SC|HR|FZ|VS|SW|SN|CR|SE|SI|SO|LP|SG|NH|SP|IZ|ST|BF|TE|HV|OD|SR|S|AC|DW|ZW|TF|TS|TR|TÜ|UM|PZ|TP|UE|UN|UH|MN|KK|VB|V|AE|PL|RC|VG|GW|PW|VR|VK|KB|WA|WT|BE|WM|WE|AP|MO|WW|FB|WZ|WI|WB|JE|WF|WO|W|WÜ|BL|Z|GC)[- ]?[A-Z]{1,2}[- ]?\d{1,4}|(AIC|FDB|ABG|SLN|SAW|KLZ|BUL|ESB|NAB|SUL|WST|ABI|AZE|BTF|KÖT|DKB|FEU|ROT|ALZ|SMÜ|WER|AUR|NOR|DÜW|BRK|HAB|TÖL|WOR|BAD|BAR|BER|BIW|EBS|KEM|MÜB|PEG|BGL|BGD|REI|WIL|BKS|BIR|WAT|BOR|BOH|BOT|BRB|BLK|HHM|NEB|NMB|WSF|LEO|HDL|WMS|WZL|BÜS|CHA|KÖZ|ROD|WÜM|CLP|NEC|COC|ZEL|COE|CUX|DAH|LDS|DEG|DEL|RSL|DLG|DGF|LAN|HEI|MED|DON|KIB|ROK|JÜL|MON|SLE|EBE|EIC|HIG|WBS|BIT|PRÜ|LIB|EMD|WIT|ERH|HÖS|ERZ|ANA|ASZ|MAB|MEK|STL|SZB|FDS|HCH|HOR|WOL|FRG|GRA|WOS|FRI|FFB|GAP|GER|BRL|CLZ|GTH|NOH|HGW|GRZ|LÖB|NOL|WSW|DUD|HMÜ|OHA|KRU|HAL|HAM|HBS|QLB|HVL|NAU|HAS|EBN|GEO|HOH|HDH|ERK|HER|WAN|HEF|ROF|HBN|ALF|HSK|USI|NAI|REH|SAN|KÜN|ÖHR|HOL|WAR|ARN|BRG|GNT|HOG|WOH|KEH|MAI|PAR|RID|ROL|KLE|GEL|KUS|KYF|ART|SDH|LDK|DIL|MAL|VIB|LER|BNA|GHA|GRM|MTL|WUR|LEV|LIF|STE|WEL|LIP|VAI|LUP|HGN|LBZ|LWL|PCH|STB|DAN|MKK|SLÜ|MSP|TBB|MGH|MTK|BIN|MSH|EIL|HET|SGH|BID|MYK|MSE|MST|MÜR|WRN|MEI|GRH|RIE|MZG|MIL|OBB|BED|FLÖ|MOL|FRW|SEE|SRB|AIB|MOS|BCH|ILL|SOB|NMS|NEA|SEF|UFF|NEW|VOH|NDH|TDO|NWM|GDB|GVM|WIS|NOM|EIN|GAN|LAU|HEB|OHV|OSL|SFB|ERB|LOS|BSK|KEL|BSB|MEL|WTL|OAL|FÜS|MOD|OHZ|OPR|BÜR|PAF|PLÖ|CAS|GLA|REG|VIT|ECK|SIM|GOA|EMS|DIZ|GOH|RÜD|SWA|NES|KÖN|MET|LRO|BÜZ|DBR|ROS|TET|HRO|ROW|BRV|HIP|PAN|GRI|SHK|EIS|SRO|SOK|LBS|SCZ|MER|QFT|SLF|SLS|HOM|SLK|ASL|BBG|SBK|SFT|SHG|MGN|MEG|ZIG|SAD|NEN|OVI|SHA|BLB|SIG|SON|SPN|FOR|GUB|SPB|IGB|WND|STD|STA|SDL|OBG|HST|BOG|SHL|PIR|FTL|SEB|SÖM|SÜW|TIR|SAB|TUT|ANG|SDT|LÜN|LSZ|MHL|VEC|VER|VIE|OVL|ANK|OVP|SBG|UEM|UER|WLG|GMN|NVP|RDG|RÜG|DAU|FKB|WAF|WAK|SLZ|WEN|SOG|APD|WUG|GUN|ESW|WIZ|WES|DIN|BRA|BÜD|WHV|HWI|GHC|WTM|WOB|WUN|MAK|SEL|OCH|HOT|WDA)[- ]?(([A-Z][- ]?\d{1,4})|([A-Z]{2}[- ]?\d{1,3})))[- ]?(E|H)?$/.test(str),
+ 'de-LI': str => /^FL[- ]?\d{1,5}[UZ]?$/.test(str),
+ 'pt-PT': str =>
+ /^([A-Z]{2}|[0-9]{2})[ -·]?([A-Z]{2}|[0-9]{2})[ -·]?([A-Z]{2}|[0-9]{2})$/.test(str),
+ 'sq-AL': str =>
+ /^[A-Z]{2}[- ]?((\d{3}[- ]?(([A-Z]{2})|T))|(R[- ]?\d{3}))$/.test(str),
+ 'pt-BR': str =>
+ /^[A-Z]{3}[ -]?[0-9][A-Z][0-9]{2}|[A-Z]{3}[ -]?[0-9]{4}$/.test(str),
+};
+
+export default function isLicensePlate(str, locale) {
+ assertString(str);
+ if (locale in validators) {
+ return validators[locale](str);
+ } else if (locale === 'any') {
+ for (const key in validators) {
+ /* eslint guard-for-in: 0 */
+ const validator = validators[key];
+ if (validator(str)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ throw new Error(`Invalid locale '${locale}'`);
+}
diff --git a/src/lib/isLocale.js b/src/lib/isLocale.js
index ab66e5c59..cacac8aec 100644
--- a/src/lib/isLocale.js
+++ b/src/lib/isLocale.js
@@ -1,6 +1,6 @@
import assertString from './util/assertString';
-const localeReg = /^[A-z]{2,4}([_-]([A-z]{4}|[\d]{3}))?([_-]([A-z]{2}|[\d]{3}))?$/;
+const localeReg = /^[A-Za-z]{2,4}([_-]([A-Za-z]{4}|[\d]{3}))?([_-]([A-Za-z]{2}|[\d]{3}))?$/;
export default function isLocale(str) {
assertString(str);
diff --git a/src/lib/isMACAddress.js b/src/lib/isMACAddress.js
index 458c72c64..8ffc8c254 100644
--- a/src/lib/isMACAddress.js
+++ b/src/lib/isMACAddress.js
@@ -1,19 +1,18 @@
import assertString from './util/assertString';
-const macAddress = /^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/;
-const macAddressNoColons = /^([0-9a-fA-F]){12}$/;
-const macAddressWithHyphen = /^([0-9a-fA-F][0-9a-fA-F]-){5}([0-9a-fA-F][0-9a-fA-F])$/;
-const macAddressWithSpaces = /^([0-9a-fA-F][0-9a-fA-F]\s){5}([0-9a-fA-F][0-9a-fA-F])$/;
-const macAddressWithDots = /^([0-9a-fA-F]{4}).([0-9a-fA-F]{4}).([0-9a-fA-F]{4})$/;
+const macAddress = /^(?:[0-9a-fA-F]{2}([-:\s]))([0-9a-fA-F]{2}\1){4}([0-9a-fA-F]{2})$/;
+const macAddressNoSeparators = /^([0-9a-fA-F]){12}$/;
+const macAddressWithDots = /^([0-9a-fA-F]{4}\.){2}([0-9a-fA-F]{4})$/;
export default function isMACAddress(str, options) {
assertString(str);
- if (options && options.no_colons) {
- return macAddressNoColons.test(str);
+ /**
+ * @deprecated `no_colons` TODO: remove it in the next major
+ */
+ if (options && (options.no_colons || options.no_separators)) {
+ return macAddressNoSeparators.test(str);
}
return macAddress.test(str)
- || macAddressWithHyphen.test(str)
- || macAddressWithSpaces.test(str)
|| macAddressWithDots.test(str);
}
diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js
index 119a4c14c..95b568547 100644
--- a/src/lib/isMobilePhone.js
+++ b/src/lib/isMobilePhone.js
@@ -13,6 +13,7 @@ const phones = {
'ar-KW': /^(\+?965)[569]\d{7}$/,
'ar-LY': /^((\+?218)|0)?(9[1-6]\d{7}|[1-8]\d{7,9})$/,
'ar-MA': /^(?:(?:\+|00)212|0)[5-7]\d{8}$/,
+ 'ar-OM': /^((\+|00)968)?(9[1-9])\d{6}$/,
'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/,
'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/,
'ar-TN': /^(\+?216)?[2459]\d{7}$/,
@@ -26,13 +27,13 @@ const phones = {
'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/,
'de-DE': /^(\+49)?0?[1|3]([0|5][0-45-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7}$/,
'de-AT': /^(\+43|0)\d{1,4}\d{3,12}$/,
- 'de-CH': /^(\+41|0)(7[5-9])\d{1,7}$/,
+ 'de-CH': /^(\+41|0)([1-9])\d{1,9}$/,
'de-LU': /^(\+352)?((6\d1)\d{6})$/,
'el-GR': /^(\+?30|0)?(69\d{8})$/,
'en-AU': /^(\+?61|0)4\d{8}$/,
'en-GB': /^(\+?44|0)7\d{9}$/,
'en-GG': /^(\+?44|0)1481\d{6}$/,
- 'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28)\d{7}$/,
+ 'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28|55|59)\d{7}$/,
'en-HK': /^(\+?852[-\s]?)?[456789]\d{3}[-\s]?\d{4}$/,
'en-MO': /^(\+?853[-\s]?)?[6]\d{3}[-\s]?\d{4}$/,
'en-IE': /^(\+?353|0)8[356789]\d{7}$/,
@@ -45,8 +46,8 @@ const phones = {
'en-PK': /^((\+92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$/,
'en-PH': /^(09|\+639)\d{9}$/,
'en-RW': /^(\+?250|0)?[7]\d{8}$/,
- 'en-SG': /^(\+65)?[689]\d{7}$/,
- 'en-SL': /^(?:0|94|\+94)?(7(0|1|2|5|6|7|8)( |-)?\d)\d{6}$/,
+ 'en-SG': /^(\+65)?[3689]\d{7}$/,
+ 'en-SL': /^(\+?232|0)\d{8}$/,
'en-TZ': /^(\+?255|0)?[67]\d{8}$/,
'en-UG': /^(\+?256|0)?[7]\d{8}$/,
'en-US': /^((\+1|1)?( |-)?)?(\([2-9][0-9]{2}\)|[2-9][0-9]{2})( |-)?([2-9][0-9]{2}( |-)?[0-9]{4})$/,
@@ -55,7 +56,7 @@ const phones = {
'en-ZW': /^(\+263)[0-9]{9}$/,
'es-AR': /^\+?549(11|[2368]\d)\d{8}$/,
'es-BO': /^(\+?591)?(6|7)\d{7}$/,
- 'es-CO': /^(\+?57)?([1-8]{1}|3[0-9]{2})?[2-9]{1}\d{6}$/,
+ 'es-CO': /^(\+?57)?3(0(0|1|2|4|5)|1\d|2[0-4]|5(0|1))\d{7}$/,
'es-CL': /^(\+?56|0)[2-9]\d{1}\d{7}$/,
'es-CR': /^(\+506)?[2-8]\d{7}$/,
'es-DO': /^(\+?1)?8[024]9\d{7}$/,
@@ -88,7 +89,9 @@ const phones = {
'kl-GL': /^(\+?299)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
'ko-KR': /^((\+?82)[ \-]?)?0?1([0|1|6|7|8|9]{1})[ \-]?\d{3,4}[ \-]?\d{4}$/,
'lt-LT': /^(\+370|8)\d{8}$/,
+ 'lv-LV': /^(\+?371)2\d{7}$/,
'ms-MY': /^(\+?6?01){1}(([0145]{1}(\-|\s)?\d{7,8})|([236789]{1}(\s|\-)?\d{7}))$/,
+ 'mz-MZ': /^(\+?258)?8[234567]\d{7}$/,
'nb-NO': /^(\+?47)?[49]\d{7}$/,
'ne-NP': /^(\+?977)?9[78]\d{8}$/,
'nl-BE': /^(\+?32|0)4?\d{8}$/,
@@ -97,8 +100,10 @@ const phones = {
'pl-PL': /^(\+?48)? ?[5-8]\d ?\d{3} ?\d{2} ?\d{2}$/,
'pt-BR': /^((\+?55\ ?[1-9]{2}\ ?)|(\+?55\ ?\([1-9]{2}\)\ ?)|(0[1-9]{2}\ ?)|(\([1-9]{2}\)\ ?)|([1-9]{2}\ ?))((\d{4}\-?\d{4})|(9[2-9]{1}\d{3}\-?\d{4}))$/,
'pt-PT': /^(\+?351)?9[1236]\d{7}$/,
+ 'pt-AO': /^(\+244)\d{9}$/,
'ro-RO': /^(\+?4?0)\s?7\d{2}(\/|\s|\.|\-)?\d{3}(\s|\.|\-)?\d{3}$/,
'ru-RU': /^(\+?7|8)?9\d{9}$/,
+ 'si-LK': /^(?:0|94|\+94)?(7(0|1|2|5|6|7|8)( |-)?\d)\d{6}$/,
'sl-SI': /^(\+386\s?|0)(\d{1}\s?\d{3}\s?\d{2}\s?\d{2}|\d{2}\s?\d{3}\s?\d{3})$/,
'sk-SK': /^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
'sq-AL': /^(\+355|0)6[789]\d{6}$/,
@@ -108,8 +113,8 @@ const phones = {
'tr-TR': /^(\+?90|0)?5\d{9}$/,
'uk-UA': /^(\+?38|8)?0\d{9}$/,
'uz-UZ': /^(\+?998)?(6[125-79]|7[1-69]|88|9\d)\d{7}$/,
- 'vi-VN': /^(\+?84|0)((3([2-9]))|(5([2689]))|(7([0|6-9]))|(8([1-6|89]))|(9([0-9])))([0-9]{7})$/,
- 'zh-CN': /^((\+|00)86)?1([3568][0-9]|4[579]|6[67]|7[01235678]|9[012356789])[0-9]{8}$/,
+ 'vi-VN': /^(\+?84|0)((3([2-9]))|(5([2689]))|(7([0|6-9]))|(8([1-9]))|(9([0-9])))([0-9]{7})$/,
+ 'zh-CN': /^((\+|00)86)?1([3456789][0-9]|4[579]|6[67]|7[01235678]|9[012356789])[0-9]{8}$/,
'zh-TW': /^(\+?886\-?|0)?9\d{8}$/,
};
/* eslint-enable max-len */
@@ -121,6 +126,8 @@ phones['fr-BE'] = phones['nl-BE'];
phones['zh-HK'] = phones['en-HK'];
phones['zh-MO'] = phones['en-MO'];
phones['ga-IE'] = phones['en-IE'];
+phones['fr-CH'] = phones['de-CH'];
+phones['it-CH'] = phones['fr-CH'];
export default function isMobilePhone(str, locale, options) {
assertString(str);
diff --git a/src/lib/isPassportNumber.js b/src/lib/isPassportNumber.js
index 8a7716f80..51a8e70ac 100644
--- a/src/lib/isPassportNumber.js
+++ b/src/lib/isPassportNumber.js
@@ -13,6 +13,7 @@ const passportRegexByCountryCode = {
AU: /^[A-Z]\d{7}$/, // AUSTRALIA
BE: /^[A-Z]{2}\d{6}$/, // BELGIUM
BG: /^\d{9}$/, // BULGARIA
+ BR: /^[A-Z]{2}\d{6}$/, // BRAZIL
BY: /^[A-Z]{2}\d{7}$/, // BELARUS
CA: /^[A-Z]{2}\d{6}$/, // CANADA
CH: /^[A-Z]\d{7}$/, // SWITZERLAND
@@ -32,6 +33,7 @@ const passportRegexByCountryCode = {
HU: /^[A-Z]{2}(\d{6}|\d{7})$/, // HUNGARY
IE: /^[A-Z0-9]{2}\d{7}$/, // IRELAND
IN: /^[A-Z]{1}-?\d{7}$/, // INDIA
+ IR: /^[A-Z]\d{8}$/, // IRAN
IS: /^(A)\d{7}$/, // ICELAND
IT: /^[A-Z0-9]{2}\d{7}$/, // ITALY
JP: /^[A-Z]{2}\d{7}$/, // JAPAN
@@ -39,7 +41,10 @@ const passportRegexByCountryCode = {
LT: /^[A-Z0-9]{8}$/, // LITHUANIA
LU: /^[A-Z0-9]{8}$/, // LUXEMBURG
LV: /^[A-Z0-9]{2}\d{7}$/, // LATVIA
+ LY: /^[A-Z0-9]{8}$/, // LIBYA
MT: /^\d{7}$/, // MALTA
+ MZ: /^([A-Z]{2}\d{7})|(\d{2}[A-Z]{2}\d{5})$/, // MOZAMBIQUE
+ MY: /^[AHK]\d{8}$/, // MALAYSIA
NL: /^[A-Z]{2}[A-Z0-9]{6}\d$/, // NETHERLANDS
PO: /^[A-Z]{2}\d{7}$/, // POLAND
PT: /^[A-Z]\d{6}$/, // PORTUGAL
diff --git a/src/lib/isPostalCode.js b/src/lib/isPostalCode.js
index 23b373497..915c27f2b 100644
--- a/src/lib/isPostalCode.js
+++ b/src/lib/isPostalCode.js
@@ -33,7 +33,7 @@ const patterns = {
HT: /^HT\d{4}$/,
HU: fourDigit,
ID: fiveDigit,
- IE: /^(?!.*(?:o))[A-z]\d[\dw]\s\w{4}$/i,
+ IE: /^(?!.*(?:o))[A-Za-z]\d[\dw]\s\w{4}$/i,
IL: /^(\d{5}|\d{7})$/,
IN: /^((?!10|29|35|54|55|65|66|86|87|88|89)[1-9][0-9]{5})$/,
IR: /\b(?!(\d)\1{3})[13-9]{4}[1346-9][013-9]{5}\b/,
@@ -41,6 +41,7 @@ const patterns = {
IT: fiveDigit,
JP: /^\d{3}\-\d{4}$/,
KE: fiveDigit,
+ KR: /^(\d{5}|\d{6})$/,
LI: /^(948[5-9]|949[0-7])$/,
LT: /^LT\-\d{5}$/,
LU: fourDigit,
diff --git a/src/lib/isSlug.js b/src/lib/isSlug.js
index da0193137..28b872a92 100644
--- a/src/lib/isSlug.js
+++ b/src/lib/isSlug.js
@@ -1,6 +1,6 @@
import assertString from './util/assertString';
-let charsetRegex = /^[^\s-_](?!.*?[-_]{2,})([a-z0-9-\\]{1,})[^\s]*[^-_\s]$/;
+let charsetRegex = /^[^\s-_](?!.*?[-_]{2,})[a-z0-9-\\][^\s]*[^-_\s]$/;
export default function isSlug(str) {
assertString(str);
diff --git a/src/lib/isStrongPassword.js b/src/lib/isStrongPassword.js
index 7433703ad..28bb0637f 100644
--- a/src/lib/isStrongPassword.js
+++ b/src/lib/isStrongPassword.js
@@ -4,7 +4,7 @@ import assertString from './util/assertString';
const upperCaseRegex = /^[A-Z]$/;
const lowerCaseRegex = /^[a-z]$/;
const numberRegex = /^[0-9]$/;
-const symbolRegex = /^[-#!$%^&*()_+|~=`{}\[\]:";'<>?,.\/ ]$/;
+const symbolRegex = /^[-#!$@%^&*()_+|~=`{}\[\]:";'<>?,.\/ ]$/;
const defaultOptions = {
minLength: 8,
@@ -49,6 +49,7 @@ function analyzePassword(password) {
symbolCount: 0,
};
Object.keys(charMap).forEach((char) => {
+ /* istanbul ignore else */
if (upperCaseRegex.test(char)) {
analysis.uppercaseCount += charMap[char];
} else if (lowerCaseRegex.test(char)) {
diff --git a/src/lib/isTaxID.js b/src/lib/isTaxID.js
index 40edfe381..f1ebae6d9 100644
--- a/src/lib/isTaxID.js
+++ b/src/lib/isTaxID.js
@@ -280,7 +280,7 @@ function elGrCheck(tin) {
for (let i = 0; i < 8; i++) {
checksum += digits[i] * (2 ** (8 - i));
}
- return checksum % 11 === digits[8];
+ return ((checksum % 11) % 10) === digits[8];
}
/*
@@ -852,6 +852,93 @@ function plPlCheck(tin) {
return checksum === parseInt(tin[10], 10);
}
+/*
+* pt-BR validation function
+* (Cadastro de Pessoas Físicas (CPF, persons)
+* Cadastro Nacional de Pessoas Jurídicas (CNPJ, entities)
+* Both inputs will be validated
+*/
+
+function ptBrCheck(tin) {
+ tin = tin.replace(/[^\d]+/g, '');
+ if (tin === '') return false;
+
+ if (tin.length === 11) {
+ let sum;
+ let ramainder;
+ sum = 0;
+ tin = tin.replace(/[^\d]+/g, '');
+
+ if ( // Reject known invalid CPFs
+ tin === '11111111111' ||
+ tin === '22222222222' ||
+ tin === '33333333333' ||
+ tin === '44444444444' ||
+ tin === '55555555555' ||
+ tin === '66666666666' ||
+ tin === '77777777777' ||
+ tin === '88888888888' ||
+ tin === '99999999999' ||
+ tin === '00000000000'
+ ) return false;
+
+ for (let i = 1; i <= 9; i++) sum += parseInt(tin.substring(i - 1, i), 10) * (11 - i);
+ ramainder = (sum * 10) % 11;
+ if ((ramainder === 10) || (ramainder === 11)) ramainder = 0;
+ if (ramainder !== parseInt(tin.substring(9, 10), 10)) return false;
+ sum = 0;
+
+ for (let i = 1; i <= 10; i++) sum += parseInt(tin.substring(i - 1, i), 10) * (12 - i);
+ ramainder = (sum * 10) % 11;
+ if ((ramainder === 10) || (ramainder === 11)) ramainder = 0;
+ if (ramainder !== parseInt(tin.substring(10, 11), 10)) return false;
+
+ return true;
+ }
+
+ if (tin.length !== 14) { return false; }
+
+ if ( // Reject know invalid CNPJs
+ tin === '00000000000000' ||
+ tin === '11111111111111' ||
+ tin === '22222222222222' ||
+ tin === '33333333333333' ||
+ tin === '44444444444444' ||
+ tin === '55555555555555' ||
+ tin === '66666666666666' ||
+ tin === '77777777777777' ||
+ tin === '88888888888888' ||
+ tin === '99999999999999') { return false; }
+
+ let length = tin.length - 2;
+ let identifiers = tin.substring(0, length);
+ let verificators = tin.substring(length);
+ let sum = 0;
+ let pos = length - 7;
+
+ for (let i = length; i >= 1; i--) {
+ sum += identifiers.charAt(length - i) * pos;
+ pos -= 1;
+ if (pos < 2) { pos = 9; }
+ }
+ let result = sum % 11 < 2 ? 0 : 11 - (sum % 11);
+ if (result !== parseInt(verificators.charAt(0), 10)) { return false; }
+
+ length += 1;
+ identifiers = tin.substring(0, length);
+ sum = 0;
+ pos = length - 7;
+ for (let i = length; i >= 1; i--) {
+ sum += identifiers.charAt(length - i) * pos;
+ pos -= 1;
+ if (pos < 2) { pos = 9; }
+ }
+ result = sum % 11 < 2 ? 0 : 11 - (sum % 11);
+ if (result !== parseInt(verificators.charAt(1), 10)) { return false; }
+
+ return true;
+}
+
/*
* pt-PT validation function
* (Número de identificação fiscal (NIF), persons/entities)
@@ -1039,6 +1126,7 @@ const taxIdFormat = {
'mt-MT': /^\d{3,7}[APMGLHBZ]$|^([1-8])\1\d{7}$/i,
'nl-NL': /^\d{9}$/,
'pl-PL': /^\d{10,11}$/,
+ 'pt-BR': /^\d{11,14}$/,
'pt-PT': /^\d{9}$/,
'ro-RO': /^\d{13}$/,
'sk-SK': /^\d{6}\/{0,1}\d{3,4}$/,
@@ -1076,6 +1164,7 @@ const taxIdCheck = {
'mt-MT': mtMtCheck,
'nl-NL': nlNlCheck,
'pl-PL': plPlCheck,
+ 'pt-BR': ptBrCheck,
'pt-PT': ptPtCheck,
'ro-RO': roRoCheck,
'sk-SK': skSkCheck,
diff --git a/src/lib/isURL.js b/src/lib/isURL.js
index 6fe5651e5..4306e5deb 100644
--- a/src/lib/isURL.js
+++ b/src/lib/isURL.js
@@ -101,8 +101,11 @@ export default function isURL(url, options) {
if (options.disallow_auth) {
return false;
}
+ if (split[0] === '' || split[0].substr(0, 1) === ':') {
+ return false;
+ }
auth = split.shift();
- if (auth.indexOf(':') === -1 || (auth.indexOf(':') >= 0 && auth.split(':').length > 2)) {
+ if (auth.indexOf(':') >= 0 && auth.split(':').length > 2) {
return false;
}
}
diff --git a/src/lib/isVAT.js b/src/lib/isVAT.js
index 49084f191..549bf336f 100644
--- a/src/lib/isVAT.js
+++ b/src/lib/isVAT.js
@@ -2,6 +2,7 @@ import assertString from './util/assertString';
export const vatMatchers = {
GB: /^GB((\d{3} \d{4} ([0-8][0-9]|9[0-6]))|(\d{9} \d{3})|(((GD[0-4])|(HA[5-9]))[0-9]{2}))$/,
+ IT: /^(IT)?[0-9]{11}$/,
};
export default function isVAT(str, countryCode) {
diff --git a/src/lib/rtrim.js b/src/lib/rtrim.js
index b53d23f57..d10aaa9de 100644
--- a/src/lib/rtrim.js
+++ b/src/lib/rtrim.js
@@ -3,6 +3,6 @@ import assertString from './util/assertString';
export default function rtrim(str, chars) {
assertString(str);
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
- const pattern = chars ? new RegExp(`[${chars.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}]+$`, 'g') : /\s+$/g;
+ const pattern = chars ? new RegExp(`[${chars.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}]+$`, 'g') : /(\s)+$/g;
return str.replace(pattern, '');
}
diff --git a/src/lib/util/typeOf.js b/src/lib/util/typeOf.js
new file mode 100644
index 000000000..f96af511a
--- /dev/null
+++ b/src/lib/util/typeOf.js
@@ -0,0 +1,10 @@
+/**
+ * Better way to handle type checking
+ * null, {}, array and date are objects, which confuses
+ */
+export default function typeOf(input) {
+ const rawObject = Object.prototype.toString.call(input).toLowerCase();
+ const typeOfRegex = /\[object (.*)]/g;
+ const type = typeOfRegex.exec(rawObject)[1];
+ return type;
+}
diff --git a/test/util.js b/test/util.js
new file mode 100644
index 000000000..449cd9ee7
--- /dev/null
+++ b/test/util.js
@@ -0,0 +1,20 @@
+/**
+ * All tests that tests any utility.
+ * Prevent any breaking of functionality
+ */
+import assert from 'assert';
+import typeOf from '../src/lib/util/typeOf';
+
+describe('Util', () => {
+ it('should validate different typeOf', () => {
+ assert.strictEqual(typeOf([]), 'array');
+ assert.strictEqual(typeOf(null), 'null');
+ assert.strictEqual(typeOf({}), 'object');
+ assert.strictEqual(typeOf(new Date()), 'date');
+ assert.strictEqual(typeOf('ezkemboi'), 'string');
+ assert.strictEqual(typeOf(String('kemboi')), 'string');
+ assert.strictEqual(typeOf(undefined), 'undefined');
+ assert.strictEqual(typeOf(2021), 'number');
+ assert.notStrictEqual(typeOf([]), 'object');
+ });
+});
diff --git a/test/validators.js b/test/validators.js
index f47d3ac0f..31b7f960e 100644
--- a/test/validators.js
+++ b/test/validators.js
@@ -79,6 +79,7 @@ describe('Validators', () => {
`${repeat('a', 31)}@gmail.com`,
'test@gmail.com',
'test.1@gmail.com',
+ 'test@1337.com',
],
invalid: [
'invalidemail@',
@@ -349,6 +350,7 @@ describe('Validators', () => {
'http://www.foobar.com/~foobar',
'http://user:pass@www.foobar.com/',
'http://user:@www.foobar.com/',
+ 'http://user@www.foobar.com',
'http://127.0.0.1/',
'http://10.0.0.0/',
'http://189.123.14.13/',
@@ -373,7 +375,7 @@ describe('Validators', () => {
'http://[::FFFF:129.144.52.38]:80/index.html',
'http://[2010:836B:4179::836B:4179]',
'http://example.com/example.json#/foo/bar',
- 'http://user:@www.foobar.com',
+ 'http://1337.com',
],
invalid: [
'http://localhost:3000/',
@@ -403,6 +405,8 @@ describe('Validators', () => {
'http://lol: @foobar.com/',
'http://www.foo_bar.com/',
'http://www.foobar.com/\t',
+ 'http://@foobar.com',
+ 'http://:@foobar.com',
'http://\n@www.foobar.com/',
'',
`http://foobar.com/${new Array(2083).join('f')}`,
@@ -414,7 +418,6 @@ describe('Validators', () => {
'////foobar.com',
'http:////foobar.com',
'https://example.com/foo//',
- 'myemail@mail.com',
],
});
});
@@ -666,6 +669,24 @@ describe('Validators', () => {
});
});
+ it('should accept urls containing authentication information', () => {
+ test({
+ validator: 'isURL',
+ args: [{ disallow_auth: false }],
+ valid: [
+ 'user@example.com',
+ 'user:@example.com',
+ 'user:password@example.com',
+ ],
+ invalid: [
+ 'user:user:password@example.com',
+ '@example.com',
+ ':@example.com',
+ ':example.com',
+ ],
+ });
+ });
+
it('should allow user to skip URL length validation', () => {
test({
validator: 'isURL',
@@ -717,21 +738,23 @@ describe('Validators', () => {
invalid: [
'abc',
'01:02:03:04:05',
+ '01:02:03:04:05:z0',
'01:02:03:04::ab',
'1:2:3:4:5:6',
'AB:CD:EF:GH:01:02',
'A9C5 D4 9F EB D3',
'01-02 03:04 05 ab',
'0102.03:04.05ab',
+ '900f/dffs/sdea',
],
});
});
- it('should validate MAC addresses without colons', () => {
+ it('should validate MAC addresses without separator', () => {
test({
validator: 'isMACAddress',
args: [{
- no_colons: true,
+ no_separators: true,
}],
valid: [
'abababababab',
@@ -767,6 +790,7 @@ describe('Validators', () => {
'1.2.3.4',
'::1',
'2001:db8:0000:1:1:1:1:1',
+ '2001:db8:3:4::192.0.2.33',
'2001:41d0:2:a141::1',
'::ffff:127.0.0.1',
'::0000',
@@ -775,8 +799,33 @@ describe('Validators', () => {
'1111:1:1:1:1:1:1:1',
'fe80::a6db:30ff:fe98:e946',
'::',
+ '::8',
'::ffff:127.0.0.1',
+ '::ffff:255.255.255.255',
+ '::ffff:0:255.255.255.255',
+ '::2:3:4:5:6:7:8',
+ '::255.255.255.255',
'0:0:0:0:0:ffff:127.0.0.1',
+ '1:2:3:4:5:6:7::',
+ '1:2:3:4:5:6::8',
+ '1::7:8',
+ '1:2:3:4:5::7:8',
+ '1:2:3:4:5::8',
+ '1::6:7:8',
+ '1:2:3:4::6:7:8',
+ '1:2:3:4::8',
+ '1::5:6:7:8',
+ '1:2:3::5:6:7:8',
+ '1:2:3::8',
+ '1::4:5:6:7:8',
+ '1:2::4:5:6:7:8',
+ '1:2::8',
+ '1::3:4:5:6:7:8',
+ '1::8',
+ 'fe80::7:8%eth0',
+ 'fe80::7:8%1',
+ '64:ff9b::192.0.2.33',
+ '0:0:0:0:0:0:10.0.0.1',
],
invalid: [
'abc',
@@ -868,18 +917,88 @@ describe('Validators', () => {
'127.0.0.1/24',
'0.0.0.0/0',
'255.255.255.0/32',
+ '::/0',
+ '::/128',
+ '2001::/128',
+ '2001:800::/128',
+ '::ffff:127.0.0.1/128',
],
invalid: [
+ 'abc',
'127.200.230.1/35',
'127.200.230.1/-1',
'1.1.1.1/011',
- '::1/64',
'1.1.1/24.1',
'1.1.1.1/01',
'1.1.1.1/1.1',
'1.1.1.1/1.',
'1.1.1.1/1/1',
'1.1.1.1',
+ '::1',
+ '::1/164',
+ '2001::/240',
+ '2001::/-1',
+ '2001::/001',
+ '2001::/24.1',
+ '2001:db8:0000:1:1:1:1:1',
+ '::ffff:127.0.0.1',
+ ],
+ });
+ test({
+ validator: 'isIPRange',
+ args: [4],
+ valid: [
+ '127.0.0.1/1',
+ '0.0.0.0/1',
+ '255.255.255.255/1',
+ '1.2.3.4/1',
+ '255.0.0.1/1',
+ '0.0.1.1/1',
+ ],
+ invalid: [
+ 'abc',
+ '::1',
+ '2001:db8:0000:1:1:1:1:1',
+ '::ffff:127.0.0.1',
+ '137.132.10.01',
+ '0.256.0.256',
+ '255.256.255.256',
+ ],
+ });
+ test({
+ validator: 'isIPRange',
+ args: [6],
+ valid: [
+ '::1/1',
+ '2001:db8:0000:1:1:1:1:1/1',
+ '::ffff:127.0.0.1/1',
+ ],
+ invalid: [
+ 'abc',
+ '127.0.0.1',
+ '0.0.0.0',
+ '255.255.255.255',
+ '1.2.3.4',
+ '::ffff:287.0.0.1',
+ '::ffff:287.0.0.1/254',
+ '%',
+ 'fe80::1234%',
+ 'fe80::1234%1%3%4',
+ 'fe80%fe80%',
+ ],
+ });
+ test({
+ validator: 'isIPRange',
+ args: [10],
+ valid: [],
+ invalid: [
+ 'abc',
+ '127.0.0.1/1',
+ '0.0.0.0/1',
+ '255.255.255.255/1',
+ '1.2.3.4/1',
+ '::1/1',
+ '2001:db8:0000:1:1:1:1:1/1',
],
});
});
@@ -894,6 +1013,7 @@ describe('Validators', () => {
'foo--bar.com',
'xn--froschgrn-x9a.com',
'rebecca.blackfriday',
+ '1337.com',
],
invalid: [
'abc',
@@ -1568,6 +1688,45 @@ describe('Validators', () => {
});
});
+ it('should validate alphanumeric string with ignored characters', () => {
+ test({
+ validator: 'isAlphanumeric',
+ args: ['en-US', { ignore: '@_- ' }], // ignore [@ space _ -]
+ valid: [
+ 'Hello@123',
+ 'this is a valid alphaNumeric string',
+ 'En-US @ alpha_numeric',
+ ],
+ invalid: [
+ 'In*Valid',
+ 'hello$123',
+ '{invalid}',
+ ],
+ });
+
+ test({
+ validator: 'isAlphanumeric',
+ args: ['en-US', { ignore: /[\s/-]/g }], // ignore [space -]
+ valid: [
+ 'en-US',
+ 'this is a valid alphaNumeric string',
+ ],
+ invalid: [
+ 'INVALID$ AlphaNum Str',
+ 'hello@123',
+ 'abc*123',
+ ],
+ });
+
+ test({
+ validator: 'isAlphanumeric',
+ args: ['en-US', { ignore: 1234 }], // invalid ignore matcher (ignore should be instance of a String or RegExp)
+ error: [
+ 'alpha',
+ ],
+ });
+ });
+
it('should validate defined english aliases', () => {
test({
validator: 'isAlphanumeric',
@@ -2245,6 +2404,18 @@ describe('Validators', () => {
],
});
+ test({
+ validator: 'isPassportNumber',
+ args: ['BR'],
+ valid: [
+ 'FZ973689',
+ 'GH231233',
+ ],
+ invalid: [
+ 'ABX29332',
+ ],
+ });
+
test({
validator: 'isPassportNumber',
args: ['BY'],
@@ -2497,6 +2668,21 @@ describe('Validators', () => {
],
});
+ test({
+ validator: 'isPassportNumber',
+ args: ['IR'],
+ valid: [
+ 'J97634522',
+ 'A01234567',
+ 'Z11977831',
+ ],
+ invalid: [
+ 'A0123456',
+ 'A0123456Z',
+ '012345678',
+ ],
+ });
+
test({
validator: 'isPassportNumber',
args: ['IS'],
@@ -2587,6 +2773,19 @@ describe('Validators', () => {
'4017173LV',
],
});
+ test({
+ validator: 'isPassportNumber',
+ args: ['LY'],
+ valid: [
+ 'P79JF34X',
+ 'RJ45H4V2',
+ ],
+ invalid: [
+ 'P79JF34',
+ 'RJ45H4V2C',
+ 'RJ4-H4V2',
+ ],
+ });
test({
validator: 'isPassportNumber',
@@ -2599,6 +2798,32 @@ describe('Validators', () => {
'MT01234',
],
});
+ test({
+ validator: 'isPassportNumber',
+ args: ['MZ'],
+ valid: [
+ 'AB0808212',
+ '08AB12123',
+ ],
+ invalid: [
+ '1AB011241',
+ '1AB01121',
+ 'ABAB01121',
+ ],
+ });
+ test({
+ validator: 'isPassportNumber',
+ args: ['MY'],
+ valid: [
+ 'A00000000',
+ 'H12345678',
+ 'K43143233',
+ ],
+ invalid: [
+ 'A1234567',
+ 'C01234567',
+ ],
+ });
test({
validator: 'isPassportNumber',
@@ -4258,6 +4483,7 @@ describe('Validators', () => {
'BR1500000000000010932840814P2',
'LB92000700000000123123456123',
'IR200170000000339545727003',
+ 'MZ97123412341234123412341',
],
invalid: [
'XX22YYY1234567890123',
@@ -4391,6 +4617,31 @@ describe('Validators', () => {
'X1234567L',
],
},
+ {
+ locale: 'IR',
+ valid: [
+ '0499370899',
+ '0790419904',
+ '0084575948',
+ '0963695398',
+ '0684159414',
+ '0067749828',
+ '0650451252',
+ '1583250689',
+ '4032152314',
+ '0076229645',
+ '4271467685',
+ '0200203241',
+ ],
+ invalid: [
+ '1260293040',
+ '0000000001',
+ '1999999999',
+ '9999999991',
+ 'AAAAAAAAAA',
+ '0684159415',
+ ],
+ },
{
locale: 'IT',
valid: [
@@ -4458,6 +4709,24 @@ describe('Validators', () => {
'336000842',
],
},
+ {
+ locale: 'ar-LY',
+ valid: [
+ '119803455876',
+ '120024679875',
+ '219624876201',
+ '220103480657',
+ ],
+ invalid: [
+ '987654320123',
+ '123-456-7890',
+ '012345678912',
+ '1234567890',
+ 'AFJBHUYTREWR',
+ 'C4V6B1X0M5T6',
+ '9876543210123',
+ ],
+ },
{
locale: 'ar-TN',
valid: [
@@ -4607,6 +4876,7 @@ describe('Validators', () => {
'GB0001411924',
'DE000WCH8881',
'PLLWBGD00016',
+ 'US0378331005',
],
invalid: [
'DE000BAY0018',
@@ -4679,6 +4949,9 @@ describe('Validators', () => {
'9771234567003',
'9783161484100',
'73513537',
+ '00012345600012',
+ '10012345678902',
+ '20012345678909',
],
invalid: [
'5901234123451',
@@ -5361,6 +5634,25 @@ describe('Validators', () => {
'00212408186135',
],
},
+ {
+ locale: 'ar-OM',
+ valid: [
+ '+96891212121',
+ '0096899999999',
+ '93112211',
+ '99099009',
+ ],
+ invalid: [
+ '+96890212121',
+ '0096890999999',
+ '0090999999',
+ '+9689021212',
+ '',
+ '+212234',
+ '+21',
+ '02122333',
+ ],
+ },
{
locale: 'ar-SY',
valid: [
@@ -5563,6 +5855,50 @@ describe('Validators', () => {
'064349089895623459',
],
},
+ {
+ locale: 'mz-MZ',
+ valid: [
+ '+258849229754',
+ '258849229754',
+ '849229754',
+ '829229754',
+ '839229754',
+ '869229754',
+ '859229754',
+ '869229754',
+ '879229754',
+ '+258829229754',
+ '+258839229754',
+ '+258869229754',
+ '+258859229754',
+ '+258869229754',
+ '+258879229754',
+ '258829229754',
+ '258839229754',
+ '258869229754',
+ '258859229754',
+ '258869229754',
+ '258879229754',
+ ],
+ invalid: [
+ '+248849229754',
+ '158849229754',
+ '249229754',
+ '819229754',
+ '899229754',
+ '889229754',
+ '89229754',
+ '8619229754',
+ '87922975411',
+ '257829229754',
+ '+255839229754',
+ '+2258869229754',
+ '+1258859229754',
+ '+2588692297541',
+ '+2588792519754',
+ '25882922975411',
+ ],
+ },
{
locale: 'pt-BR',
valid: [
@@ -5750,6 +6086,8 @@ describe('Validators', () => {
'+233562345671',
'+233232345671',
'+233282345671',
+ '+233592349493',
+ '0550298219',
],
invalid: [
'082123',
@@ -6139,6 +6477,7 @@ describe('Validators', () => {
{
locale: 'en-SG',
valid: [
+ '32891278',
'87654321',
'98765432',
'+6587654321',
@@ -6146,6 +6485,7 @@ describe('Validators', () => {
'+6565241234',
],
invalid: [
+ '332891231',
'987654321',
'876543219',
'8765432',
@@ -6252,6 +6592,25 @@ describe('Validators', () => {
'+99676338855',
],
},
+ {
+ locale: 'si-LK',
+ valid: [
+ '+94766661206',
+ '94713114340',
+ '0786642116',
+ '078 7642116',
+ '078-7642116',
+
+ ],
+ invalid: [
+ '9912349956789',
+ '12345',
+ '1678123456',
+ '0731234567',
+ '0749994567',
+ '0797878674',
+ ],
+ },
{
locale: 'sr-RS',
valid: [
@@ -6369,6 +6728,7 @@ describe('Validators', () => {
'0883805866',
'0892405867',
'+84888696413',
+ '0878123456',
],
invalid: [
'12345',
@@ -6407,16 +6767,11 @@ describe('Validators', () => {
valid: [
'+573003321235',
'573003321235',
- '579871235',
'3003321235',
'3213321235',
'3103321235',
- '3253321235',
- '3321235',
- '574321235',
- '5784321235',
- '5784321235',
- '9821235',
+ '3243321235',
+ '573011140876',
],
invalid: [
'1234',
@@ -6428,8 +6783,14 @@ describe('Validators', () => {
'5714003425432',
'5703013347567',
'069834567',
- '0698345',
'969834567',
+ '579871235',
+ '574321235',
+ '5784321235',
+ '5784321235',
+ '9821235',
+ '0698345',
+ '3321235',
],
},
{
@@ -7280,20 +7641,16 @@ describe('Validators', () => {
{
locale: 'en-SL',
valid: [
- '+94766661206',
- '94713114340',
- '0786642116',
- '078 7642116',
- '078-7642116',
-
+ '+23274560591',
+ '23274560591',
+ '074560591',
],
invalid: [
- '9912349956789',
+ '0745605912',
'12345',
- '1678123456',
- '0731234567',
- '0749994567',
+ '232745605917',
'0797878674',
+ '23274560591 ',
],
},
{
@@ -7379,6 +7736,34 @@ describe('Validators', () => {
'NotANumber',
],
},
+ {
+ locale: 'pt-AO',
+ valid: [
+ '+244911123432',
+ '+244123091232',
+ ],
+ invalid: [
+ '+2449111234321',
+ '31234',
+ '31234567',
+ '512345',
+ 'NotANumber',
+ ],
+ },
+ {
+ locale: 'lv-LV',
+ valid: [
+ '+37121234567',
+ '37121234567',
+ ],
+ invalid: [
+ '+37201234567',
+ '+3754321',
+ '3712123456',
+ '+371212345678',
+ 'NotANumber',
+ ],
+ },
];
let allValid = [];
@@ -7450,7 +7835,7 @@ describe('Validators', () => {
});
});
- // de-CH
+ // de-CH, fr-CH, it-CH
test({
validator: 'isMobilePhone',
valid: [
@@ -7459,9 +7844,10 @@ describe('Validators', () => {
'+41771112233',
'+41781112233',
'+41791112233',
+ '+411122112211',
],
invalid: [
- '+41441112233',
+ '+41041112233',
],
args: [],
});
@@ -8433,11 +8819,17 @@ describe('Validators', () => {
'1MUz4VMYui5qY1mxUiG8BQ1Luv6tqkvaiL',
'3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy',
'bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq',
+ '14qViLJfdGaP4EeHnDyJbEGQysnCpwk3gd',
+ '35bSzXvRKLpHsHMrzb82f617cV4Srnt7hS',
+ '17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhemt',
+ 'bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4',
],
invalid: [
'4J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy',
'0x56F0B8A998425c53c75C4A303D4eF987533c5597',
'pp8skudq3x5hzw8ew7vzsw8tn4k8wxsqsv0lt0mf3g',
+ '17VZNX1SN5NlKa8UQFxwQbFeFc3iqRYhem',
+ 'BC1QW508D6QEJXTDG4Y5R3ZARVAYR0C5XW7KV8F3T4',
],
});
});
@@ -9356,6 +9748,17 @@ describe('Validators', () => {
'ab1234',
],
},
+ {
+ locale: 'KR',
+ valid: [
+ '17008',
+ '339012',
+ ],
+ invalid: [
+ '1412347',
+ 'ab1234',
+ ],
+ },
];
let allValid = [];
@@ -9571,6 +9974,7 @@ describe('Validators', () => {
args: ['el-GR'],
valid: [
'758426713',
+ '032792320',
'054100004'],
invalid: [
'054100005',
@@ -9843,6 +10247,22 @@ describe('Validators', () => {
'2234567855',
'02223013623'],
});
+ test({
+ validator: 'isTaxID',
+ args: ['pt-BR'],
+ valid: [
+ '35161990910',
+ '74407265027',
+ '05423994000172',
+ '11867044000130'],
+ invalid: [
+ '170.691.440-72',
+ '01494282042',
+ '11111111111',
+ '94.592.973/0001-82',
+ '28592361000192',
+ '11111111111111'],
+ });
test({
validator: 'isTaxID',
args: ['pt-PT'],
@@ -9952,8 +10372,15 @@ describe('Validators', () => {
it('should validate slug', () => {
test({
validator: 'isSlug',
- args: ['cs_67CZ'],
- valid: ['cs-cz', 'cscz'],
+ valid: [
+ 'foo',
+ 'foo-bar',
+ 'foo_bar',
+ 'foo-bar-foo',
+ 'foo-bar_foo',
+ 'foo-bar_foo*75-b4r-**_foo',
+ 'foo-bar_foo*75-b4r-**_foo-&&',
+ ],
invalid: [
'not-----------slug',
'@#_$@',
@@ -10165,7 +10592,133 @@ describe('Validators', () => {
],
});
});
-
+ it('should be valid license plate', () => {
+ test({
+ validator: 'isLicensePlate',
+ args: ['pt-PT'],
+ valid: [
+ 'AA-12-34',
+ '12·34·AB',
+ '12·AB·34',
+ 'AB 12 CD',
+ 'AB12CD',
+ ],
+ invalid: [
+ '',
+ 'notalicenseplate',
+ 'A1-B2-C3',
+ 'ABC-1-EF',
+ ],
+ });
+ test({
+ validator: 'isLicensePlate',
+ args: ['de-LI'],
+ valid: [
+ 'FL 1',
+ 'FL 99999',
+ 'FL 1337',
+ ],
+ invalid: [
+ '',
+ 'FL 999999',
+ 'AB 12345',
+ 'FL -1',
+ ],
+ });
+ test({
+ validator: 'isLicensePlate',
+ args: ['de-DE'],
+ valid: [
+ 'M A 1',
+ 'M A 12',
+ 'M A 123',
+ 'M A 1234',
+ 'M AB 1',
+ 'M AB 12',
+ 'M AB 123',
+ 'M AB 1234',
+ 'FS A 1',
+ 'FS A 12',
+ 'FS A 123',
+ 'FS A 1234',
+ 'FS AB 1',
+ 'FS AB 12',
+ 'FS AB 123',
+ 'FS AB 1234',
+ 'FSAB1234',
+ 'FS-AB-1234',
+ 'FS AB 1234 H',
+ 'FS AB 1234 E',
+ 'FSAB1234E',
+ 'FS-AB-1234-E',
+ ],
+ invalid: [
+ 'YY AB 123',
+ 'PAF AB 1234',
+ 'M ABC 123',
+ 'M AB 12345',
+ 'FS AB 1234 A',
+ ],
+ });
+ test({
+ validator: 'isLicensePlate',
+ args: ['sq-AL'],
+ valid: [
+ 'AA 000 AA',
+ 'ZZ 999 ZZ',
+ ],
+ invalid: [
+ '',
+ 'AA 0 A',
+ 'AAA 00 AAA',
+ ],
+ });
+ test({
+ validator: 'isLicensePlate',
+ args: ['pt-BR'],
+ valid: [
+ 'ABC1234',
+ 'ABC 1234',
+ 'ABC-1234',
+ 'ABC1D23',
+ 'ABC1K23',
+ 'ABC1Z23',
+ 'ABC 1D23',
+ 'ABC-1D23',
+ ],
+ invalid: [
+ '',
+ 'AA 0 A',
+ 'AAA 00 AAA',
+ 'ABCD123',
+ 'AB12345',
+ 'AB123DC',
+ ],
+ });
+ test({
+ validator: 'isLicensePlate',
+ args: ['any'],
+ valid: [
+ 'FL 1',
+ 'FS AB 123',
+ ],
+ invalid: [
+ '',
+ 'FL 999999',
+ 'FS AB 1234 A',
+ ],
+ });
+ test({
+ validator: 'isLicensePlate',
+ args: ['asdfasdf'],
+ error: [
+ 'FL 1',
+ 'FS AB 123',
+ 'FL 999999',
+ 'FS AB 1234 A',
+ ],
+ });
+ });
it('should validate english VAT numbers', () => {
test({
validator: 'isVAT',
@@ -10197,6 +10750,22 @@ describe('Validators', () => {
],
});
+ test({
+ validator: 'isVAT',
+ args: ['IT'],
+ valid: [
+ 'IT12345678910',
+ '12345678910',
+ ],
+ invalid: [
+ 'IT12345678 910',
+ 'IT 123456789101',
+ 'IT123456789101',
+ 'GB12345678910',
+ 'IT123456789',
+ ],
+ });
+
test({
validator: 'isVAT',
args: ['invalidCountryCode'],
diff --git a/validator.js b/validator.js
deleted file mode 100644
index 662c73ce0..000000000
--- a/validator.js
+++ /dev/null
@@ -1,4726 +0,0 @@
-/*!
- * Copyright (c) 2018 Chris O'Hara
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-(function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
- typeof define === 'function' && define.amd ? define(factory) :
- (global.validator = factory());
-}(this, (function () { 'use strict';
-
-function _typeof(obj) {
- "@babel/helpers - typeof";
-
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
- _typeof = function (obj) {
- return typeof obj;
- };
- } else {
- _typeof = function (obj) {
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
- };
- }
-
- return _typeof(obj);
-}
-
-function _slicedToArray(arr, i) {
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
-}
-
-function _toConsumableArray(arr) {
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
-}
-
-function _arrayWithoutHoles(arr) {
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
-}
-
-function _arrayWithHoles(arr) {
- if (Array.isArray(arr)) return arr;
-}
-
-function _iterableToArray(iter) {
- if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
-}
-
-function _iterableToArrayLimit(arr, i) {
- if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
- var _arr = [];
- var _n = true;
- var _d = false;
- var _e = undefined;
-
- try {
- for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
- _arr.push(_s.value);
-
- if (i && _arr.length === i) break;
- }
- } catch (err) {
- _d = true;
- _e = err;
- } finally {
- try {
- if (!_n && _i["return"] != null) _i["return"]();
- } finally {
- if (_d) throw _e;
- }
- }
-
- return _arr;
-}
-
-function _unsupportedIterableToArray(o, minLen) {
- if (!o) return;
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
- var n = Object.prototype.toString.call(o).slice(8, -1);
- if (n === "Object" && o.constructor) n = o.constructor.name;
- if (n === "Map" || n === "Set") return Array.from(o);
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
-}
-
-function _arrayLikeToArray(arr, len) {
- if (len == null || len > arr.length) len = arr.length;
-
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
-
- return arr2;
-}
-
-function _nonIterableSpread() {
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
-}
-
-function _nonIterableRest() {
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
-}
-
-function _createForOfIteratorHelper(o, allowArrayLike) {
- var it;
-
- if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
- if (it) o = it;
- var i = 0;
-
- var F = function () {};
-
- return {
- s: F,
- n: function () {
- if (i >= o.length) return {
- done: true
- };
- return {
- done: false,
- value: o[i++]
- };
- },
- e: function (e) {
- throw e;
- },
- f: F
- };
- }
-
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
- }
-
- var normalCompletion = true,
- didErr = false,
- err;
- return {
- s: function () {
- it = o[Symbol.iterator]();
- },
- n: function () {
- var step = it.next();
- normalCompletion = step.done;
- return step;
- },
- e: function (e) {
- didErr = true;
- err = e;
- },
- f: function () {
- try {
- if (!normalCompletion && it.return != null) it.return();
- } finally {
- if (didErr) throw err;
- }
- }
- };
-}
-
-function assertString(input) {
- var isString = typeof input === 'string' || input instanceof String;
-
- if (!isString) {
- var invalidType = _typeof(input);
-
- if (input === null) invalidType = 'null';else if (invalidType === 'object') invalidType = input.constructor.name;
- throw new TypeError("Expected a string but received a ".concat(invalidType));
- }
-}
-
-function toDate(date) {
- assertString(date);
- date = Date.parse(date);
- return !isNaN(date) ? new Date(date) : null;
-}
-
-var alpha = {
- 'en-US': /^[A-Z]+$/i,
- 'az-AZ': /^[A-VXYZÇƏĞİıÖŞÜ]+$/i,
- 'bg-BG': /^[А-Я]+$/i,
- 'cs-CZ': /^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,
- 'da-DK': /^[A-ZÆØÅ]+$/i,
- 'de-DE': /^[A-ZÄÖÜß]+$/i,
- 'el-GR': /^[Α-ώ]+$/i,
- 'es-ES': /^[A-ZÁÉÍÑÓÚÜ]+$/i,
- 'fa-IR': /^[ابپتثجچحخدذرزژسشصضطظعغفقکگلمنوهی]+$/i,
- 'fr-FR': /^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,
- 'it-IT': /^[A-ZÀÉÈÌÎÓÒÙ]+$/i,
- 'nb-NO': /^[A-ZÆØÅ]+$/i,
- 'nl-NL': /^[A-ZÁÉËÏÓÖÜÚ]+$/i,
- 'nn-NO': /^[A-ZÆØÅ]+$/i,
- 'hu-HU': /^[A-ZÁÉÍÓÖŐÚÜŰ]+$/i,
- 'pl-PL': /^[A-ZĄĆĘŚŁŃÓŻŹ]+$/i,
- 'pt-PT': /^[A-ZÃÁÀÂÄÇÉÊËÍÏÕÓÔÖÚÜ]+$/i,
- 'ru-RU': /^[А-ЯЁ]+$/i,
- 'sl-SI': /^[A-ZČĆĐŠŽ]+$/i,
- 'sk-SK': /^[A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i,
- 'sr-RS@latin': /^[A-ZČĆŽŠĐ]+$/i,
- 'sr-RS': /^[А-ЯЂЈЉЊЋЏ]+$/i,
- 'sv-SE': /^[A-ZÅÄÖ]+$/i,
- 'th-TH': /^[ก-๐\s]+$/i,
- 'tr-TR': /^[A-ZÇĞİıÖŞÜ]+$/i,
- 'uk-UA': /^[А-ЩЬЮЯЄIЇҐі]+$/i,
- 'vi-VN': /^[A-ZÀÁẠẢÃÂẦẤẬẨẪĂẰẮẶẲẴĐÈÉẸẺẼÊỀẾỆỂỄÌÍỊỈĨÒÓỌỎÕÔỒỐỘỔỖƠỜỚỢỞỠÙÚỤỦŨƯỪỨỰỬỮỲÝỴỶỸ]+$/i,
- 'ku-IQ': /^[ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
- ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
- he: /^[א-ת]+$/,
- fa: /^['آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی']+$/i
-};
-var alphanumeric = {
- 'en-US': /^[0-9A-Z]+$/i,
- 'az-AZ': /^[0-9A-VXYZÇƏĞİıÖŞÜ]+$/i,
- 'bg-BG': /^[0-9А-Я]+$/i,
- 'cs-CZ': /^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,
- 'da-DK': /^[0-9A-ZÆØÅ]+$/i,
- 'de-DE': /^[0-9A-ZÄÖÜß]+$/i,
- 'el-GR': /^[0-9Α-ω]+$/i,
- 'es-ES': /^[0-9A-ZÁÉÍÑÓÚÜ]+$/i,
- 'fr-FR': /^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,
- 'it-IT': /^[0-9A-ZÀÉÈÌÎÓÒÙ]+$/i,
- 'hu-HU': /^[0-9A-ZÁÉÍÓÖŐÚÜŰ]+$/i,
- 'nb-NO': /^[0-9A-ZÆØÅ]+$/i,
- 'nl-NL': /^[0-9A-ZÁÉËÏÓÖÜÚ]+$/i,
- 'nn-NO': /^[0-9A-ZÆØÅ]+$/i,
- 'pl-PL': /^[0-9A-ZĄĆĘŚŁŃÓŻŹ]+$/i,
- 'pt-PT': /^[0-9A-ZÃÁÀÂÄÇÉÊËÍÏÕÓÔÖÚÜ]+$/i,
- 'ru-RU': /^[0-9А-ЯЁ]+$/i,
- 'sl-SI': /^[0-9A-ZČĆĐŠŽ]+$/i,
- 'sk-SK': /^[0-9A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i,
- 'sr-RS@latin': /^[0-9A-ZČĆŽŠĐ]+$/i,
- 'sr-RS': /^[0-9А-ЯЂЈЉЊЋЏ]+$/i,
- 'sv-SE': /^[0-9A-ZÅÄÖ]+$/i,
- 'th-TH': /^[ก-๙\s]+$/i,
- 'tr-TR': /^[0-9A-ZÇĞİıÖŞÜ]+$/i,
- 'uk-UA': /^[0-9А-ЩЬЮЯЄIЇҐі]+$/i,
- 'ku-IQ': /^[٠١٢٣٤٥٦٧٨٩0-9ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
- 'vi-VN': /^[0-9A-ZÀÁẠẢÃÂẦẤẬẨẪĂẰẮẶẲẴĐÈÉẸẺẼÊỀẾỆỂỄÌÍỊỈĨÒÓỌỎÕÔỒỐỘỔỖƠỜỚỢỞỠÙÚỤỦŨƯỪỨỰỬỮỲÝỴỶỸ]+$/i,
- ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
- he: /^[0-9א-ת]+$/,
- fa: /^['0-9آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی۱۲۳۴۵۶۷۸۹۰']+$/i
-};
-var decimal = {
- 'en-US': '.',
- ar: '٫'
-};
-var englishLocales = ['AU', 'GB', 'HK', 'IN', 'NZ', 'ZA', 'ZM'];
-
-for (var locale, i = 0; i < englishLocales.length; i++) {
- locale = "en-".concat(englishLocales[i]);
- alpha[locale] = alpha['en-US'];
- alphanumeric[locale] = alphanumeric['en-US'];
- decimal[locale] = decimal['en-US'];
-} // Source: http://www.localeplanet.com/java/
-
-
-var arabicLocales = ['AE', 'BH', 'DZ', 'EG', 'IQ', 'JO', 'KW', 'LB', 'LY', 'MA', 'QM', 'QA', 'SA', 'SD', 'SY', 'TN', 'YE'];
-
-for (var _locale, _i = 0; _i < arabicLocales.length; _i++) {
- _locale = "ar-".concat(arabicLocales[_i]);
- alpha[_locale] = alpha.ar;
- alphanumeric[_locale] = alphanumeric.ar;
- decimal[_locale] = decimal.ar;
-}
-
-var farsiLocales = ['IR', 'AF'];
-
-for (var _locale2, _i2 = 0; _i2 < farsiLocales.length; _i2++) {
- _locale2 = "fa-".concat(farsiLocales[_i2]);
- alphanumeric[_locale2] = alphanumeric.fa;
- decimal[_locale2] = decimal.ar;
-} // Source: https://en.wikipedia.org/wiki/Decimal_mark
-
-
-var dotDecimal = ['ar-EG', 'ar-LB', 'ar-LY'];
-var commaDecimal = ['bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-ZM', 'es-ES', 'fr-CA', 'fr-FR', 'id-ID', 'it-IT', 'ku-IQ', 'hu-HU', 'nb-NO', 'nn-NO', 'nl-NL', 'pl-PL', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS@latin', 'sr-RS', 'sv-SE', 'tr-TR', 'uk-UA', 'vi-VN'];
-
-for (var _i3 = 0; _i3 < dotDecimal.length; _i3++) {
- decimal[dotDecimal[_i3]] = decimal['en-US'];
-}
-
-for (var _i4 = 0; _i4 < commaDecimal.length; _i4++) {
- decimal[commaDecimal[_i4]] = ',';
-}
-
-alpha['fr-CA'] = alpha['fr-FR'];
-alphanumeric['fr-CA'] = alphanumeric['fr-FR'];
-alpha['pt-BR'] = alpha['pt-PT'];
-alphanumeric['pt-BR'] = alphanumeric['pt-PT'];
-decimal['pt-BR'] = decimal['pt-PT']; // see #862
-
-alpha['pl-Pl'] = alpha['pl-PL'];
-alphanumeric['pl-Pl'] = alphanumeric['pl-PL'];
-decimal['pl-Pl'] = decimal['pl-PL']; // see #1455
-
-alpha['fa-AF'] = alpha.fa;
-
-function isFloat(str, options) {
- assertString(str);
- options = options || {};
-
- var _float = new RegExp("^(?:[-+])?(?:[0-9]+)?(?:\\".concat(options.locale ? decimal[options.locale] : '.', "[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$"));
-
- if (str === '' || str === '.' || str === '-' || str === '+') {
- return false;
- }
-
- var value = parseFloat(str.replace(',', '.'));
- return _float.test(str) && (!options.hasOwnProperty('min') || value >= options.min) && (!options.hasOwnProperty('max') || value <= options.max) && (!options.hasOwnProperty('lt') || value < options.lt) && (!options.hasOwnProperty('gt') || value > options.gt);
-}
-var locales = Object.keys(decimal);
-
-function toFloat(str) {
- if (!isFloat(str)) return NaN;
- return parseFloat(str);
-}
-
-function toInt(str, radix) {
- assertString(str);
- return parseInt(str, radix || 10);
-}
-
-function toBoolean(str, strict) {
- assertString(str);
-
- if (strict) {
- return str === '1' || /^true$/i.test(str);
- }
-
- return str !== '0' && !/^false$/i.test(str) && str !== '';
-}
-
-function equals(str, comparison) {
- assertString(str);
- return str === comparison;
-}
-
-function toString$1(input) {
- if (_typeof(input) === 'object' && input !== null) {
- if (typeof input.toString === 'function') {
- input = input.toString();
- } else {
- input = '[object Object]';
- }
- } else if (input === null || typeof input === 'undefined' || isNaN(input) && !input.length) {
- input = '';
- }
-
- return String(input);
-}
-
-function merge() {
- var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- var defaults = arguments.length > 1 ? arguments[1] : undefined;
-
- for (var key in defaults) {
- if (typeof obj[key] === 'undefined') {
- obj[key] = defaults[key];
- }
- }
-
- return obj;
-}
-
-var defaulContainsOptions = {
- ignoreCase: false
-};
-function contains(str, elem, options) {
- assertString(str);
- options = merge(options, defaulContainsOptions);
- return options.ignoreCase ? str.toLowerCase().indexOf(toString$1(elem).toLowerCase()) >= 0 : str.indexOf(toString$1(elem)) >= 0;
-}
-
-function matches(str, pattern, modifiers) {
- assertString(str);
-
- if (Object.prototype.toString.call(pattern) !== '[object RegExp]') {
- pattern = new RegExp(pattern, modifiers);
- }
-
- return pattern.test(str);
-}
-
-/* eslint-disable prefer-rest-params */
-
-function isByteLength(str, options) {
- assertString(str);
- var min;
- var max;
-
- if (_typeof(options) === 'object') {
- min = options.min || 0;
- max = options.max;
- } else {
- // backwards compatibility: isByteLength(str, min [, max])
- min = arguments[1];
- max = arguments[2];
- }
-
- var len = encodeURI(str).split(/%..|./).length - 1;
- return len >= min && (typeof max === 'undefined' || len <= max);
-}
-
-var default_fqdn_options = {
- require_tld: true,
- allow_underscores: false,
- allow_trailing_dot: false,
- allow_numeric_tld: false
-};
-function isFQDN(str, options) {
- assertString(str);
- options = merge(options, default_fqdn_options);
- /* Remove the optional trailing dot before checking validity */
-
- if (options.allow_trailing_dot && str[str.length - 1] === '.') {
- str = str.substring(0, str.length - 1);
- }
-
- var parts = str.split('.');
-
- for (var i = 0; i < parts.length; i++) {
- if (parts[i].length > 63) {
- return false;
- }
- }
-
- if (options.require_tld) {
- var tld = parts.pop();
-
- if (!parts.length || !/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
- return false;
- } // disallow spaces && special characers
-
-
- if (/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20\u00A9\uFFFD]/.test(tld)) {
- return false;
- }
- }
-
- for (var part, _i = 0; _i < parts.length; _i++) {
- part = parts[_i];
-
- if (!options.allow_numeric_tld && _i === parts.length - 1 && /^\d+$/.test(part)) {
- return false; // reject numeric TLDs
- }
-
- if (!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(part)) {
- return false;
- } // disallow full-width chars
-
-
- if (/[\uff01-\uff5e]/.test(part)) {
- return false;
- }
-
- if (part[0] === '-' || part[part.length - 1] === '-') {
- return false;
- }
-
- if (!options.allow_underscores && /_/.test(part)) {
- return false;
- }
- }
-
- return true;
-}
-
-/**
-11.3. Examples
-
- The following addresses
-
- fe80::1234 (on the 1st link of the node)
- ff02::5678 (on the 5th link of the node)
- ff08::9abc (on the 10th organization of the node)
-
- would be represented as follows:
-
- fe80::1234%1
- ff02::5678%5
- ff08::9abc%10
-
- (Here we assume a natural translation from a zone index to the
- part, where the Nth zone of any scope is translated into
- "N".)
-
- If we use interface names as , those addresses could also be
- represented as follows:
-
- fe80::1234%ne0
- ff02::5678%pvc1.3
- ff08::9abc%interface10
-
- where the interface "ne0" belongs to the 1st link, "pvc1.3" belongs
- to the 5th link, and "interface10" belongs to the 10th organization.
- * * */
-
-var ipv4Maybe = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/;
-var ipv6Block = /^[0-9A-F]{1,4}$/i;
-function isIP(str) {
- var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
- assertString(str);
- version = String(version);
-
- if (!version) {
- return isIP(str, 4) || isIP(str, 6);
- } else if (version === '4') {
- if (!ipv4Maybe.test(str)) {
- return false;
- }
-
- var parts = str.split('.').sort(function (a, b) {
- return a - b;
- });
- return parts[3] <= 255;
- } else if (version === '6') {
- var addressAndZone = [str]; // ipv6 addresses could have scoped architecture
- // according to https://tools.ietf.org/html/rfc4007#section-11
-
- if (str.includes('%')) {
- addressAndZone = str.split('%');
-
- if (addressAndZone.length !== 2) {
- // it must be just two parts
- return false;
- }
-
- if (!addressAndZone[0].includes(':')) {
- // the first part must be the address
- return false;
- }
-
- if (addressAndZone[1] === '') {
- // the second part must not be empty
- return false;
- }
- }
-
- var blocks = addressAndZone[0].split(':');
- var foundOmissionBlock = false; // marker to indicate ::
- // At least some OS accept the last 32 bits of an IPv6 address
- // (i.e. 2 of the blocks) in IPv4 notation, and RFC 3493 says
- // that '::ffff:a.b.c.d' is valid for IPv4-mapped IPv6 addresses,
- // and '::a.b.c.d' is deprecated, but also valid.
-
- var foundIPv4TransitionBlock = isIP(blocks[blocks.length - 1], 4);
- var expectedNumberOfBlocks = foundIPv4TransitionBlock ? 7 : 8;
-
- if (blocks.length > expectedNumberOfBlocks) {
- return false;
- } // initial or final ::
-
-
- if (str === '::') {
- return true;
- } else if (str.substr(0, 2) === '::') {
- blocks.shift();
- blocks.shift();
- foundOmissionBlock = true;
- } else if (str.substr(str.length - 2) === '::') {
- blocks.pop();
- blocks.pop();
- foundOmissionBlock = true;
- }
-
- for (var i = 0; i < blocks.length; ++i) {
- // test for a :: which can not be at the string start/end
- // since those cases have been handled above
- if (blocks[i] === '' && i > 0 && i < blocks.length - 1) {
- if (foundOmissionBlock) {
- return false; // multiple :: in address
- }
-
- foundOmissionBlock = true;
- } else if (foundIPv4TransitionBlock && i === blocks.length - 1) {// it has been checked before that the last
- // block is a valid IPv4 address
- } else if (!ipv6Block.test(blocks[i])) {
- return false;
- }
- }
-
- if (foundOmissionBlock) {
- return blocks.length >= 1;
- }
-
- return blocks.length === expectedNumberOfBlocks;
- }
-
- return false;
-}
-
-var default_email_options = {
- allow_display_name: false,
- require_display_name: false,
- allow_utf8_local_part: true,
- require_tld: true,
- blacklisted_chars: '',
- ignore_max_length: false
-};
-/* eslint-disable max-len */
-
-/* eslint-disable no-control-regex */
-
-var splitNameAddress = /^([^\x00-\x1F\x7F-\x9F\cX]+)<(.+)>$/i;
-var emailUserPart = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i;
-var gmailUserPart = /^[a-z\d]+$/;
-var quotedEmailUser = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i;
-var emailUserUtf8Part = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i;
-var quotedEmailUserUtf8 = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i;
-var defaultMaxEmailLength = 254;
-/* eslint-enable max-len */
-
-/* eslint-enable no-control-regex */
-
-/**
- * Validate display name according to the RFC2822: https://tools.ietf.org/html/rfc2822#appendix-A.1.2
- * @param {String} display_name
- */
-
-function validateDisplayName(display_name) {
- var trim_quotes = display_name.match(/^"(.+)"$/i);
- var display_name_without_quotes = trim_quotes ? trim_quotes[1] : display_name; // display name with only spaces is not valid
-
- if (!display_name_without_quotes.trim()) {
- return false;
- } // check whether display name contains illegal character
-
-
- var contains_illegal = /[\.";<>]/.test(display_name_without_quotes);
-
- if (contains_illegal) {
- // if contains illegal characters,
- // must to be enclosed in double-quotes, otherwise it's not a valid display name
- if (!trim_quotes) {
- return false;
- } // the quotes in display name must start with character symbol \
-
-
- var all_start_with_back_slash = display_name_without_quotes.split('"').length === display_name_without_quotes.split('\\"').length;
-
- if (!all_start_with_back_slash) {
- return false;
- }
- }
-
- return true;
-}
-
-function isEmail(str, options) {
- assertString(str);
- options = merge(options, default_email_options);
-
- if (options.require_display_name || options.allow_display_name) {
- var display_email = str.match(splitNameAddress);
-
- if (display_email) {
- var display_name;
-
- var _display_email = _slicedToArray(display_email, 3);
-
- display_name = _display_email[1];
- str = _display_email[2];
-
- // sometimes need to trim the last space to get the display name
- // because there may be a space between display name and email address
- // eg. myname
- // the display name is `myname` instead of `myname `, so need to trim the last space
- if (display_name.endsWith(' ')) {
- display_name = display_name.substr(0, display_name.length - 1);
- }
-
- if (!validateDisplayName(display_name)) {
- return false;
- }
- } else if (options.require_display_name) {
- return false;
- }
- }
-
- if (!options.ignore_max_length && str.length > defaultMaxEmailLength) {
- return false;
- }
-
- var parts = str.split('@');
- var domain = parts.pop();
- var user = parts.join('@');
- var lower_domain = domain.toLowerCase();
-
- if (options.domain_specific_validation && (lower_domain === 'gmail.com' || lower_domain === 'googlemail.com')) {
- /*
- Previously we removed dots for gmail addresses before validating.
- This was removed because it allows `multiple..dots@gmail.com`
- to be reported as valid, but it is not.
- Gmail only normalizes single dots, removing them from here is pointless,
- should be done in normalizeEmail
- */
- user = user.toLowerCase(); // Removing sub-address from username before gmail validation
-
- var username = user.split('+')[0]; // Dots are not included in gmail length restriction
-
- if (!isByteLength(username.replace('.', ''), {
- min: 6,
- max: 30
- })) {
- return false;
- }
-
- var _user_parts = username.split('.');
-
- for (var i = 0; i < _user_parts.length; i++) {
- if (!gmailUserPart.test(_user_parts[i])) {
- return false;
- }
- }
- }
-
- if (options.ignore_max_length === false && (!isByteLength(user, {
- max: 64
- }) || !isByteLength(domain, {
- max: 254
- }))) {
- return false;
- }
-
- if (!isFQDN(domain, {
- require_tld: options.require_tld
- })) {
- if (!options.allow_ip_domain) {
- return false;
- }
-
- if (!isIP(domain)) {
- if (!domain.startsWith('[') || !domain.endsWith(']')) {
- return false;
- }
-
- var noBracketdomain = domain.substr(1, domain.length - 2);
-
- if (noBracketdomain.length === 0 || !isIP(noBracketdomain)) {
- return false;
- }
- }
- }
-
- if (user[0] === '"') {
- user = user.slice(1, user.length - 1);
- return options.allow_utf8_local_part ? quotedEmailUserUtf8.test(user) : quotedEmailUser.test(user);
- }
-
- var pattern = options.allow_utf8_local_part ? emailUserUtf8Part : emailUserPart;
- var user_parts = user.split('.');
-
- for (var _i = 0; _i < user_parts.length; _i++) {
- if (!pattern.test(user_parts[_i])) {
- return false;
- }
- }
-
- if (options.blacklisted_chars) {
- if (user.search(new RegExp("[".concat(options.blacklisted_chars, "]+"), 'g')) !== -1) return false;
- }
-
- return true;
-}
-
-/*
-options for isURL method
-
-require_protocol - if set as true isURL will return false if protocol is not present in the URL
-require_valid_protocol - isURL will check if the URL's protocol is present in the protocols option
-protocols - valid protocols can be modified with this option
-require_host - if set as false isURL will not check if host is present in the URL
-require_port - if set as true isURL will check if port is present in the URL
-allow_protocol_relative_urls - if set as true protocol relative URLs will be allowed
-validate_length - if set as false isURL will skip string length validation (IE maximum is 2083)
-
-*/
-
-var default_url_options = {
- protocols: ['http', 'https', 'ftp'],
- require_tld: true,
- require_protocol: false,
- require_host: true,
- require_port: false,
- require_valid_protocol: true,
- allow_underscores: false,
- allow_trailing_dot: false,
- allow_protocol_relative_urls: false,
- validate_length: true
-};
-var wrapped_ipv6 = /^\[([^\]]+)\](?::([0-9]+))?$/;
-
-function isRegExp(obj) {
- return Object.prototype.toString.call(obj) === '[object RegExp]';
-}
-
-function checkHost(host, matches) {
- for (var i = 0; i < matches.length; i++) {
- var match = matches[i];
-
- if (host === match || isRegExp(match) && match.test(host)) {
- return true;
- }
- }
-
- return false;
-}
-
-function isURL(url, options) {
- assertString(url);
-
- if (!url || /[\s<>]/.test(url)) {
- return false;
- }
-
- if (url.indexOf('mailto:') === 0) {
- return false;
- }
-
- options = merge(options, default_url_options);
-
- if (options.validate_length && url.length >= 2083) {
- return false;
- }
-
- var protocol, auth, host, hostname, port, port_str, split, ipv6;
- split = url.split('#');
- url = split.shift();
- split = url.split('?');
- url = split.shift();
- split = url.split('://');
-
- if (split.length > 1) {
- protocol = split.shift().toLowerCase();
-
- if (options.require_valid_protocol && options.protocols.indexOf(protocol) === -1) {
- return false;
- }
- } else if (options.require_protocol) {
- return false;
- } else if (url.substr(0, 2) === '//') {
- if (!options.allow_protocol_relative_urls) {
- return false;
- }
-
- split[0] = url.substr(2);
- }
-
- url = split.join('://');
-
- if (url === '') {
- return false;
- }
-
- split = url.split('/');
- url = split.shift();
-
- if (url === '' && !options.require_host) {
- return true;
- }
-
- split = url.split('@');
-
- if (split.length > 1) {
- if (options.disallow_auth) {
- return false;
- }
-
- auth = split.shift();
-
- if (auth.indexOf(':') === -1 || auth.indexOf(':') >= 0 && auth.split(':').length > 2) {
- return false;
- }
- }
-
- hostname = split.join('@');
- port_str = null;
- ipv6 = null;
- var ipv6_match = hostname.match(wrapped_ipv6);
-
- if (ipv6_match) {
- host = '';
- ipv6 = ipv6_match[1];
- port_str = ipv6_match[2] || null;
- } else {
- split = hostname.split(':');
- host = split.shift();
-
- if (split.length) {
- port_str = split.join(':');
- }
- }
-
- if (port_str !== null) {
- port = parseInt(port_str, 10);
-
- if (!/^[0-9]+$/.test(port_str) || port <= 0 || port > 65535) {
- return false;
- }
- } else if (options.require_port) {
- return false;
- }
-
- if (!isIP(host) && !isFQDN(host, options) && (!ipv6 || !isIP(ipv6, 6))) {
- return false;
- }
-
- host = host || ipv6;
-
- if (options.host_whitelist && !checkHost(host, options.host_whitelist)) {
- return false;
- }
-
- if (options.host_blacklist && checkHost(host, options.host_blacklist)) {
- return false;
- }
-
- return true;
-}
-
-var macAddress = /^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/;
-var macAddressNoColons = /^([0-9a-fA-F]){12}$/;
-var macAddressWithHyphen = /^([0-9a-fA-F][0-9a-fA-F]-){5}([0-9a-fA-F][0-9a-fA-F])$/;
-var macAddressWithSpaces = /^([0-9a-fA-F][0-9a-fA-F]\s){5}([0-9a-fA-F][0-9a-fA-F])$/;
-var macAddressWithDots = /^([0-9a-fA-F]{4}).([0-9a-fA-F]{4}).([0-9a-fA-F]{4})$/;
-function isMACAddress(str, options) {
- assertString(str);
-
- if (options && options.no_colons) {
- return macAddressNoColons.test(str);
- }
-
- return macAddress.test(str) || macAddressWithHyphen.test(str) || macAddressWithSpaces.test(str) || macAddressWithDots.test(str);
-}
-
-var subnetMaybe = /^\d{1,2}$/;
-function isIPRange(str) {
- assertString(str);
- var parts = str.split('/'); // parts[0] -> ip, parts[1] -> subnet
-
- if (parts.length !== 2) {
- return false;
- }
-
- if (!subnetMaybe.test(parts[1])) {
- return false;
- } // Disallow preceding 0 i.e. 01, 02, ...
-
-
- if (parts[1].length > 1 && parts[1].startsWith('0')) {
- return false;
- }
-
- return isIP(parts[0], 4) && parts[1] <= 32 && parts[1] >= 0;
-}
-
-var default_date_options = {
- format: 'YYYY/MM/DD',
- delimiters: ['/', '-'],
- strictMode: false
-};
-
-function isValidFormat(format) {
- return /(^(y{4}|y{2})[\/-](m{1,2})[\/-](d{1,2})$)|(^(m{1,2})[\/-](d{1,2})[\/-]((y{4}|y{2})$))|(^(d{1,2})[\/-](m{1,2})[\/-]((y{4}|y{2})$))/gi.test(format);
-}
-
-function zip(date, format) {
- var zippedArr = [],
- len = Math.min(date.length, format.length);
-
- for (var i = 0; i < len; i++) {
- zippedArr.push([date[i], format[i]]);
- }
-
- return zippedArr;
-}
-
-function isDate(input, options) {
- if (typeof options === 'string') {
- // Allow backward compatbility for old format isDate(input [, format])
- options = merge({
- format: options
- }, default_date_options);
- } else {
- options = merge(options, default_date_options);
- }
-
- if (typeof input === 'string' && isValidFormat(options.format)) {
- var formatDelimiter = options.delimiters.find(function (delimiter) {
- return options.format.indexOf(delimiter) !== -1;
- });
- var dateDelimiter = options.strictMode ? formatDelimiter : options.delimiters.find(function (delimiter) {
- return input.indexOf(delimiter) !== -1;
- });
- var dateAndFormat = zip(input.split(dateDelimiter), options.format.toLowerCase().split(formatDelimiter));
- var dateObj = {};
-
- var _iterator = _createForOfIteratorHelper(dateAndFormat),
- _step;
-
- try {
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
- var _step$value = _slicedToArray(_step.value, 2),
- dateWord = _step$value[0],
- formatWord = _step$value[1];
-
- if (dateWord.length !== formatWord.length) {
- return false;
- }
-
- dateObj[formatWord.charAt(0)] = dateWord;
- }
- } catch (err) {
- _iterator.e(err);
- } finally {
- _iterator.f();
- }
-
- return new Date("".concat(dateObj.m, "/").concat(dateObj.d, "/").concat(dateObj.y)).getDate() === +dateObj.d;
- }
-
- if (!options.strictMode) {
- return Object.prototype.toString.call(input) === '[object Date]' && isFinite(input);
- }
-
- return false;
-}
-
-function isBoolean(str) {
- assertString(str);
- return ['true', 'false', '1', '0'].indexOf(str) >= 0;
-}
-
-var localeReg = /^[A-z]{2,4}([_-]([A-z]{4}|[\d]{3}))?([_-]([A-z]{2}|[\d]{3}))?$/;
-function isLocale(str) {
- assertString(str);
-
- if (str === 'en_US_POSIX' || str === 'ca_ES_VALENCIA') {
- return true;
- }
-
- return localeReg.test(str);
-}
-
-function isAlpha(_str) {
- var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US';
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
- assertString(_str);
- var str = _str;
- var ignore = options.ignore;
-
- if (ignore) {
- if (ignore instanceof RegExp) {
- str = str.replace(ignore, '');
- } else if (typeof ignore === 'string') {
- str = str.replace(new RegExp("[".concat(ignore.replace(/[-[\]{}()*+?.,\\^$|#\\s]/g, '\\$&'), "]"), 'g'), ''); // escape regex for ignore
- } else {
- throw new Error('ignore should be instance of a String or RegExp');
- }
- }
-
- if (locale in alpha) {
- return alpha[locale].test(str);
- }
-
- throw new Error("Invalid locale '".concat(locale, "'"));
-}
-var locales$1 = Object.keys(alpha);
-
-function isAlphanumeric(str) {
- var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US';
- assertString(str);
-
- if (locale in alphanumeric) {
- return alphanumeric[locale].test(str);
- }
-
- throw new Error("Invalid locale '".concat(locale, "'"));
-}
-var locales$2 = Object.keys(alphanumeric);
-
-var numericNoSymbols = /^[0-9]+$/;
-function isNumeric(str, options) {
- assertString(str);
-
- if (options && options.no_symbols) {
- return numericNoSymbols.test(str);
- }
-
- return new RegExp("^[+-]?([0-9]*[".concat((options || {}).locale ? decimal[options.locale] : '.', "])?[0-9]+$")).test(str);
-}
-
-/**
- * Reference:
- * https://en.wikipedia.org/ -- Wikipedia
- * https://docs.microsoft.com/en-us/microsoft-365/compliance/eu-passport-number -- EU Passport Number
- * https://countrycode.org/ -- Country Codes
- */
-
-var passportRegexByCountryCode = {
- AM: /^[A-Z]{2}\d{7}$/,
- // ARMENIA
- AR: /^[A-Z]{3}\d{6}$/,
- // ARGENTINA
- AT: /^[A-Z]\d{7}$/,
- // AUSTRIA
- AU: /^[A-Z]\d{7}$/,
- // AUSTRALIA
- BE: /^[A-Z]{2}\d{6}$/,
- // BELGIUM
- BG: /^\d{9}$/,
- // BULGARIA
- BY: /^[A-Z]{2}\d{7}$/,
- // BELARUS
- CA: /^[A-Z]{2}\d{6}$/,
- // CANADA
- CH: /^[A-Z]\d{7}$/,
- // SWITZERLAND
- CN: /^[GE]\d{8}$/,
- // CHINA [G=Ordinary, E=Electronic] followed by 8-digits
- CY: /^[A-Z](\d{6}|\d{8})$/,
- // CYPRUS
- CZ: /^\d{8}$/,
- // CZECH REPUBLIC
- DE: /^[CFGHJKLMNPRTVWXYZ0-9]{9}$/,
- // GERMANY
- DK: /^\d{9}$/,
- // DENMARK
- DZ: /^\d{9}$/,
- // ALGERIA
- EE: /^([A-Z]\d{7}|[A-Z]{2}\d{7})$/,
- // ESTONIA (K followed by 7-digits), e-passports have 2 UPPERCASE followed by 7 digits
- ES: /^[A-Z0-9]{2}([A-Z0-9]?)\d{6}$/,
- // SPAIN
- FI: /^[A-Z]{2}\d{7}$/,
- // FINLAND
- FR: /^\d{2}[A-Z]{2}\d{5}$/,
- // FRANCE
- GB: /^\d{9}$/,
- // UNITED KINGDOM
- GR: /^[A-Z]{2}\d{7}$/,
- // GREECE
- HR: /^\d{9}$/,
- // CROATIA
- HU: /^[A-Z]{2}(\d{6}|\d{7})$/,
- // HUNGARY
- IE: /^[A-Z0-9]{2}\d{7}$/,
- // IRELAND
- IN: /^[A-Z]{1}-?\d{7}$/,
- // INDIA
- IS: /^(A)\d{7}$/,
- // ICELAND
- IT: /^[A-Z0-9]{2}\d{7}$/,
- // ITALY
- JP: /^[A-Z]{2}\d{7}$/,
- // JAPAN
- KR: /^[MS]\d{8}$/,
- // SOUTH KOREA, REPUBLIC OF KOREA, [S=PS Passports, M=PM Passports]
- LT: /^[A-Z0-9]{8}$/,
- // LITHUANIA
- LU: /^[A-Z0-9]{8}$/,
- // LUXEMBURG
- LV: /^[A-Z0-9]{2}\d{7}$/,
- // LATVIA
- MT: /^\d{7}$/,
- // MALTA
- NL: /^[A-Z]{2}[A-Z0-9]{6}\d$/,
- // NETHERLANDS
- PO: /^[A-Z]{2}\d{7}$/,
- // POLAND
- PT: /^[A-Z]\d{6}$/,
- // PORTUGAL
- RO: /^\d{8,9}$/,
- // ROMANIA
- RU: /^\d{2}\d{2}\d{6}$/,
- // RUSSIAN FEDERATION
- SE: /^\d{8}$/,
- // SWEDEN
- SL: /^(P)[A-Z]\d{7}$/,
- // SLOVANIA
- SK: /^[0-9A-Z]\d{7}$/,
- // SLOVAKIA
- TR: /^[A-Z]\d{8}$/,
- // TURKEY
- UA: /^[A-Z]{2}\d{6}$/,
- // UKRAINE
- US: /^\d{9}$/ // UNITED STATES
-
-};
-/**
- * Check if str is a valid passport number
- * relative to provided ISO Country Code.
- *
- * @param {string} str
- * @param {string} countryCode
- * @return {boolean}
- */
-
-function isPassportNumber(str, countryCode) {
- assertString(str);
- /** Remove All Whitespaces, Convert to UPPERCASE */
-
- var normalizedStr = str.replace(/\s/g, '').toUpperCase();
- return countryCode.toUpperCase() in passportRegexByCountryCode && passportRegexByCountryCode[countryCode].test(normalizedStr);
-}
-
-var _int = /^(?:[-+]?(?:0|[1-9][0-9]*))$/;
-var intLeadingZeroes = /^[-+]?[0-9]+$/;
-function isInt(str, options) {
- assertString(str);
- options = options || {}; // Get the regex to use for testing, based on whether
- // leading zeroes are allowed or not.
-
- var regex = options.hasOwnProperty('allow_leading_zeroes') && !options.allow_leading_zeroes ? _int : intLeadingZeroes; // Check min/max/lt/gt
-
- var minCheckPassed = !options.hasOwnProperty('min') || str >= options.min;
- var maxCheckPassed = !options.hasOwnProperty('max') || str <= options.max;
- var ltCheckPassed = !options.hasOwnProperty('lt') || str < options.lt;
- var gtCheckPassed = !options.hasOwnProperty('gt') || str > options.gt;
- return regex.test(str) && minCheckPassed && maxCheckPassed && ltCheckPassed && gtCheckPassed;
-}
-
-function isPort(str) {
- return isInt(str, {
- min: 0,
- max: 65535
- });
-}
-
-function isLowercase(str) {
- assertString(str);
- return str === str.toLowerCase();
-}
-
-function isUppercase(str) {
- assertString(str);
- return str === str.toUpperCase();
-}
-
-var imeiRegexWithoutHypens = /^[0-9]{15}$/;
-var imeiRegexWithHypens = /^\d{2}-\d{6}-\d{6}-\d{1}$/;
-function isIMEI(str, options) {
- assertString(str);
- options = options || {}; // default regex for checking imei is the one without hyphens
-
- var imeiRegex = imeiRegexWithoutHypens;
-
- if (options.allow_hyphens) {
- imeiRegex = imeiRegexWithHypens;
- }
-
- if (!imeiRegex.test(str)) {
- return false;
- }
-
- str = str.replace(/-/g, '');
- var sum = 0,
- mul = 2,
- l = 14;
-
- for (var i = 0; i < l; i++) {
- var digit = str.substring(l - i - 1, l - i);
- var tp = parseInt(digit, 10) * mul;
-
- if (tp >= 10) {
- sum += tp % 10 + 1;
- } else {
- sum += tp;
- }
-
- if (mul === 1) {
- mul += 1;
- } else {
- mul -= 1;
- }
- }
-
- var chk = (10 - sum % 10) % 10;
-
- if (chk !== parseInt(str.substring(14, 15), 10)) {
- return false;
- }
-
- return true;
-}
-
-/* eslint-disable no-control-regex */
-
-var ascii = /^[\x00-\x7F]+$/;
-/* eslint-enable no-control-regex */
-
-function isAscii(str) {
- assertString(str);
- return ascii.test(str);
-}
-
-var fullWidth = /[^\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/;
-function isFullWidth(str) {
- assertString(str);
- return fullWidth.test(str);
-}
-
-var halfWidth = /[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/;
-function isHalfWidth(str) {
- assertString(str);
- return halfWidth.test(str);
-}
-
-function isVariableWidth(str) {
- assertString(str);
- return fullWidth.test(str) && halfWidth.test(str);
-}
-
-/* eslint-disable no-control-regex */
-
-var multibyte = /[^\x00-\x7F]/;
-/* eslint-enable no-control-regex */
-
-function isMultibyte(str) {
- assertString(str);
- return multibyte.test(str);
-}
-
-/**
- * Build RegExp object from an array
- * of multiple/multi-line regexp parts
- *
- * @param {string[]} parts
- * @param {string} flags
- * @return {object} - RegExp object
- */
-function multilineRegexp(parts, flags) {
- var regexpAsStringLiteral = parts.join('');
- return new RegExp(regexpAsStringLiteral, flags);
-}
-
-/**
- * Regular Expression to match
- * semantic versioning (SemVer)
- * built from multi-line, multi-parts regexp
- * Reference: https://semver.org/
- */
-
-var semanticVersioningRegex = multilineRegexp(['^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)', '(?:-((?:0|[1-9]\\d*|\\d*[a-z-][0-9a-z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-z-][0-9a-z-]*))*))', '?(?:\\+([0-9a-z-]+(?:\\.[0-9a-z-]+)*))?$'], 'i');
-function isSemVer(str) {
- assertString(str);
- return semanticVersioningRegex.test(str);
-}
-
-var surrogatePair = /[\uD800-\uDBFF][\uDC00-\uDFFF]/;
-function isSurrogatePair(str) {
- assertString(str);
- return surrogatePair.test(str);
-}
-
-var includes = function includes(arr, val) {
- return arr.some(function (arrVal) {
- return val === arrVal;
- });
-};
-
-function decimalRegExp(options) {
- var regExp = new RegExp("^[-+]?([0-9]+)?(\\".concat(decimal[options.locale], "[0-9]{").concat(options.decimal_digits, "})").concat(options.force_decimal ? '' : '?', "$"));
- return regExp;
-}
-
-var default_decimal_options = {
- force_decimal: false,
- decimal_digits: '1,',
- locale: 'en-US'
-};
-var blacklist = ['', '-', '+'];
-function isDecimal(str, options) {
- assertString(str);
- options = merge(options, default_decimal_options);
-
- if (options.locale in decimal) {
- return !includes(blacklist, str.replace(/ /g, '')) && decimalRegExp(options).test(str);
- }
-
- throw new Error("Invalid locale '".concat(options.locale, "'"));
-}
-
-var hexadecimal = /^(0x|0h)?[0-9A-F]+$/i;
-function isHexadecimal(str) {
- assertString(str);
- return hexadecimal.test(str);
-}
-
-var octal = /^(0o)?[0-7]+$/i;
-function isOctal(str) {
- assertString(str);
- return octal.test(str);
-}
-
-function isDivisibleBy(str, num) {
- assertString(str);
- return toFloat(str) % parseInt(num, 10) === 0;
-}
-
-var hexcolor = /^#?([0-9A-F]{3}|[0-9A-F]{4}|[0-9A-F]{6}|[0-9A-F]{8})$/i;
-function isHexColor(str) {
- assertString(str);
- return hexcolor.test(str);
-}
-
-var rgbColor = /^rgb\((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]),){2}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\)$/;
-var rgbaColor = /^rgba\((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]),){3}(0?\.\d|1(\.0)?|0(\.0)?)\)$/;
-var rgbColorPercent = /^rgb\((([0-9]%|[1-9][0-9]%|100%),){2}([0-9]%|[1-9][0-9]%|100%)\)/;
-var rgbaColorPercent = /^rgba\((([0-9]%|[1-9][0-9]%|100%),){3}(0?\.\d|1(\.0)?|0(\.0)?)\)/;
-function isRgbColor(str) {
- var includePercentValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
- assertString(str);
-
- if (!includePercentValues) {
- return rgbColor.test(str) || rgbaColor.test(str);
- }
-
- return rgbColor.test(str) || rgbaColor.test(str) || rgbColorPercent.test(str) || rgbaColorPercent.test(str);
-}
-
-var hslcomma = /^(hsl)a?\(\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?))(deg|grad|rad|turn|\s*)(\s*,\s*(\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%){2}\s*(,\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%?)\s*)?\)$/i;
-var hslspace = /^(hsl)a?\(\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?))(deg|grad|rad|turn|\s)(\s*(\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%){2}\s*(\/\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%?)\s*)?\)$/i;
-function isHSL(str) {
- assertString(str);
- return hslcomma.test(str) || hslspace.test(str);
-}
-
-var isrc = /^[A-Z]{2}[0-9A-Z]{3}\d{2}\d{5}$/;
-function isISRC(str) {
- assertString(str);
- return isrc.test(str);
-}
-
-/**
- * List of country codes with
- * corresponding IBAN regular expression
- * Reference: https://en.wikipedia.org/wiki/International_Bank_Account_Number
- */
-
-var ibanRegexThroughCountryCode = {
- AD: /^(AD[0-9]{2})\d{8}[A-Z0-9]{12}$/,
- AE: /^(AE[0-9]{2})\d{3}\d{16}$/,
- AL: /^(AL[0-9]{2})\d{8}[A-Z0-9]{16}$/,
- AT: /^(AT[0-9]{2})\d{16}$/,
- AZ: /^(AZ[0-9]{2})[A-Z0-9]{4}\d{20}$/,
- BA: /^(BA[0-9]{2})\d{16}$/,
- BE: /^(BE[0-9]{2})\d{12}$/,
- BG: /^(BG[0-9]{2})[A-Z]{4}\d{6}[A-Z0-9]{8}$/,
- BH: /^(BH[0-9]{2})[A-Z]{4}[A-Z0-9]{14}$/,
- BR: /^(BR[0-9]{2})\d{23}[A-Z]{1}[A-Z0-9]{1}$/,
- BY: /^(BY[0-9]{2})[A-Z0-9]{4}\d{20}$/,
- CH: /^(CH[0-9]{2})\d{5}[A-Z0-9]{12}$/,
- CR: /^(CR[0-9]{2})\d{18}$/,
- CY: /^(CY[0-9]{2})\d{8}[A-Z0-9]{16}$/,
- CZ: /^(CZ[0-9]{2})\d{20}$/,
- DE: /^(DE[0-9]{2})\d{18}$/,
- DK: /^(DK[0-9]{2})\d{14}$/,
- DO: /^(DO[0-9]{2})[A-Z]{4}\d{20}$/,
- EE: /^(EE[0-9]{2})\d{16}$/,
- EG: /^(EG[0-9]{2})\d{25}$/,
- ES: /^(ES[0-9]{2})\d{20}$/,
- FI: /^(FI[0-9]{2})\d{14}$/,
- FO: /^(FO[0-9]{2})\d{14}$/,
- FR: /^(FR[0-9]{2})\d{10}[A-Z0-9]{11}\d{2}$/,
- GB: /^(GB[0-9]{2})[A-Z]{4}\d{14}$/,
- GE: /^(GE[0-9]{2})[A-Z0-9]{2}\d{16}$/,
- GI: /^(GI[0-9]{2})[A-Z]{4}[A-Z0-9]{15}$/,
- GL: /^(GL[0-9]{2})\d{14}$/,
- GR: /^(GR[0-9]{2})\d{7}[A-Z0-9]{16}$/,
- GT: /^(GT[0-9]{2})[A-Z0-9]{4}[A-Z0-9]{20}$/,
- HR: /^(HR[0-9]{2})\d{17}$/,
- HU: /^(HU[0-9]{2})\d{24}$/,
- IE: /^(IE[0-9]{2})[A-Z0-9]{4}\d{14}$/,
- IL: /^(IL[0-9]{2})\d{19}$/,
- IQ: /^(IQ[0-9]{2})[A-Z]{4}\d{15}$/,
- IR: /^(IR[0-9]{2})0\d{2}0\d{18}$/,
- IS: /^(IS[0-9]{2})\d{22}$/,
- IT: /^(IT[0-9]{2})[A-Z]{1}\d{10}[A-Z0-9]{12}$/,
- JO: /^(JO[0-9]{2})[A-Z]{4}\d{22}$/,
- KW: /^(KW[0-9]{2})[A-Z]{4}[A-Z0-9]{22}$/,
- KZ: /^(KZ[0-9]{2})\d{3}[A-Z0-9]{13}$/,
- LB: /^(LB[0-9]{2})\d{4}[A-Z0-9]{20}$/,
- LC: /^(LC[0-9]{2})[A-Z]{4}[A-Z0-9]{24}$/,
- LI: /^(LI[0-9]{2})\d{5}[A-Z0-9]{12}$/,
- LT: /^(LT[0-9]{2})\d{16}$/,
- LU: /^(LU[0-9]{2})\d{3}[A-Z0-9]{13}$/,
- LV: /^(LV[0-9]{2})[A-Z]{4}[A-Z0-9]{13}$/,
- MC: /^(MC[0-9]{2})\d{10}[A-Z0-9]{11}\d{2}$/,
- MD: /^(MD[0-9]{2})[A-Z0-9]{20}$/,
- ME: /^(ME[0-9]{2})\d{18}$/,
- MK: /^(MK[0-9]{2})\d{3}[A-Z0-9]{10}\d{2}$/,
- MR: /^(MR[0-9]{2})\d{23}$/,
- MT: /^(MT[0-9]{2})[A-Z]{4}\d{5}[A-Z0-9]{18}$/,
- MU: /^(MU[0-9]{2})[A-Z]{4}\d{19}[A-Z]{3}$/,
- NL: /^(NL[0-9]{2})[A-Z]{4}\d{10}$/,
- NO: /^(NO[0-9]{2})\d{11}$/,
- PK: /^(PK[0-9]{2})[A-Z0-9]{4}\d{16}$/,
- PL: /^(PL[0-9]{2})\d{24}$/,
- PS: /^(PS[0-9]{2})[A-Z0-9]{4}\d{21}$/,
- PT: /^(PT[0-9]{2})\d{21}$/,
- QA: /^(QA[0-9]{2})[A-Z]{4}[A-Z0-9]{21}$/,
- RO: /^(RO[0-9]{2})[A-Z]{4}[A-Z0-9]{16}$/,
- RS: /^(RS[0-9]{2})\d{18}$/,
- SA: /^(SA[0-9]{2})\d{2}[A-Z0-9]{18}$/,
- SC: /^(SC[0-9]{2})[A-Z]{4}\d{20}[A-Z]{3}$/,
- SE: /^(SE[0-9]{2})\d{20}$/,
- SI: /^(SI[0-9]{2})\d{15}$/,
- SK: /^(SK[0-9]{2})\d{20}$/,
- SM: /^(SM[0-9]{2})[A-Z]{1}\d{10}[A-Z0-9]{12}$/,
- SV: /^(SV[0-9]{2})[A-Z0-9]{4}\d{20}$/,
- TL: /^(TL[0-9]{2})\d{19}$/,
- TN: /^(TN[0-9]{2})\d{20}$/,
- TR: /^(TR[0-9]{2})\d{5}[A-Z0-9]{17}$/,
- UA: /^(UA[0-9]{2})\d{6}[A-Z0-9]{19}$/,
- VA: /^(VA[0-9]{2})\d{18}$/,
- VG: /^(VG[0-9]{2})[A-Z0-9]{4}\d{16}$/,
- XK: /^(XK[0-9]{2})\d{16}$/
-};
-/**
- * Check whether string has correct universal IBAN format
- * The IBAN consists of up to 34 alphanumeric characters, as follows:
- * Country Code using ISO 3166-1 alpha-2, two letters
- * check digits, two digits and
- * Basic Bank Account Number (BBAN), up to 30 alphanumeric characters.
- * NOTE: Permitted IBAN characters are: digits [0-9] and the 26 latin alphabetic [A-Z]
- *
- * @param {string} str - string under validation
- * @return {boolean}
- */
-
-function hasValidIbanFormat(str) {
- // Strip white spaces and hyphens
- var strippedStr = str.replace(/[\s\-]+/gi, '').toUpperCase();
- var isoCountryCode = strippedStr.slice(0, 2).toUpperCase();
- return isoCountryCode in ibanRegexThroughCountryCode && ibanRegexThroughCountryCode[isoCountryCode].test(strippedStr);
-}
-/**
- * Check whether string has valid IBAN Checksum
- * by performing basic mod-97 operation and
- * the remainder should equal 1
- * -- Start by rearranging the IBAN by moving the four initial characters to the end of the string
- * -- Replace each letter in the string with two digits, A -> 10, B = 11, Z = 35
- * -- Interpret the string as a decimal integer and
- * -- compute the remainder on division by 97 (mod 97)
- * Reference: https://en.wikipedia.org/wiki/International_Bank_Account_Number
- *
- * @param {string} str
- * @return {boolean}
- */
-
-
-function hasValidIbanChecksum(str) {
- var strippedStr = str.replace(/[^A-Z0-9]+/gi, '').toUpperCase(); // Keep only digits and A-Z latin alphabetic
-
- var rearranged = strippedStr.slice(4) + strippedStr.slice(0, 4);
- var alphaCapsReplacedWithDigits = rearranged.replace(/[A-Z]/g, function (_char) {
- return _char.charCodeAt(0) - 55;
- });
- var remainder = alphaCapsReplacedWithDigits.match(/\d{1,7}/g).reduce(function (acc, value) {
- return Number(acc + value) % 97;
- }, '');
- return remainder === 1;
-}
-
-function isIBAN(str) {
- assertString(str);
- return hasValidIbanFormat(str) && hasValidIbanChecksum(str);
-}
-
-var isBICReg = /^[A-z]{4}[A-z]{2}\w{2}(\w{3})?$/;
-function isBIC(str) {
- assertString(str);
- return isBICReg.test(str);
-}
-
-var md5 = /^[a-f0-9]{32}$/;
-function isMD5(str) {
- assertString(str);
- return md5.test(str);
-}
-
-var lengths = {
- md5: 32,
- md4: 32,
- sha1: 40,
- sha256: 64,
- sha384: 96,
- sha512: 128,
- ripemd128: 32,
- ripemd160: 40,
- tiger128: 32,
- tiger160: 40,
- tiger192: 48,
- crc32: 8,
- crc32b: 8
-};
-function isHash(str, algorithm) {
- assertString(str);
- var hash = new RegExp("^[a-fA-F0-9]{".concat(lengths[algorithm], "}$"));
- return hash.test(str);
-}
-
-var notBase64 = /[^A-Z0-9+\/=]/i;
-var urlSafeBase64 = /^[A-Z0-9_\-]*$/i;
-var defaultBase64Options = {
- urlSafe: false
-};
-function isBase64(str, options) {
- assertString(str);
- options = merge(options, defaultBase64Options);
- var len = str.length;
-
- if (options.urlSafe) {
- return urlSafeBase64.test(str);
- }
-
- if (len % 4 !== 0 || notBase64.test(str)) {
- return false;
- }
-
- var firstPaddingChar = str.indexOf('=');
- return firstPaddingChar === -1 || firstPaddingChar === len - 1 || firstPaddingChar === len - 2 && str[len - 1] === '=';
-}
-
-function isJWT(str) {
- assertString(str);
- var dotSplit = str.split('.');
- var len = dotSplit.length;
-
- if (len > 3 || len < 2) {
- return false;
- }
-
- return dotSplit.reduce(function (acc, currElem) {
- return acc && isBase64(currElem, {
- urlSafe: true
- });
- }, true);
-}
-
-var default_json_options = {
- allow_primitives: false
-};
-function isJSON(str, options) {
- assertString(str);
-
- try {
- options = merge(options, default_json_options);
- var primitives = [];
-
- if (options.allow_primitives) {
- primitives = [null, false, true];
- }
-
- var obj = JSON.parse(str);
- return primitives.includes(obj) || !!obj && _typeof(obj) === 'object';
- } catch (e) {
- /* ignore */
- }
-
- return false;
-}
-
-var default_is_empty_options = {
- ignore_whitespace: false
-};
-function isEmpty(str, options) {
- assertString(str);
- options = merge(options, default_is_empty_options);
- return (options.ignore_whitespace ? str.trim().length : str.length) === 0;
-}
-
-/* eslint-disable prefer-rest-params */
-
-function isLength(str, options) {
- assertString(str);
- var min;
- var max;
-
- if (_typeof(options) === 'object') {
- min = options.min || 0;
- max = options.max;
- } else {
- // backwards compatibility: isLength(str, min [, max])
- min = arguments[1] || 0;
- max = arguments[2];
- }
-
- var surrogatePairs = str.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g) || [];
- var len = str.length - surrogatePairs.length;
- return len >= min && (typeof max === 'undefined' || len <= max);
-}
-
-var uuid = {
- 3: /^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,
- 4: /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
- 5: /^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
- all: /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i
-};
-function isUUID(str) {
- var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'all';
- assertString(str);
- var pattern = uuid[version];
- return pattern && pattern.test(str);
-}
-
-function isMongoId(str) {
- assertString(str);
- return isHexadecimal(str) && str.length === 24;
-}
-
-function isAfter(str) {
- var date = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : String(new Date());
- assertString(str);
- var comparison = toDate(date);
- var original = toDate(str);
- return !!(original && comparison && original > comparison);
-}
-
-function isBefore(str) {
- var date = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : String(new Date());
- assertString(str);
- var comparison = toDate(date);
- var original = toDate(str);
- return !!(original && comparison && original < comparison);
-}
-
-function isIn(str, options) {
- assertString(str);
- var i;
-
- if (Object.prototype.toString.call(options) === '[object Array]') {
- var array = [];
-
- for (i in options) {
- // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
- // istanbul ignore else
- if ({}.hasOwnProperty.call(options, i)) {
- array[i] = toString$1(options[i]);
- }
- }
-
- return array.indexOf(str) >= 0;
- } else if (_typeof(options) === 'object') {
- return options.hasOwnProperty(str);
- } else if (options && typeof options.indexOf === 'function') {
- return options.indexOf(str) >= 0;
- }
-
- return false;
-}
-
-/* eslint-disable max-len */
-
-var creditCard = /^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14})$/;
-/* eslint-enable max-len */
-
-function isCreditCard(str) {
- assertString(str);
- var sanitized = str.replace(/[- ]+/g, '');
-
- if (!creditCard.test(sanitized)) {
- return false;
- }
-
- var sum = 0;
- var digit;
- var tmpNum;
- var shouldDouble;
-
- for (var i = sanitized.length - 1; i >= 0; i--) {
- digit = sanitized.substring(i, i + 1);
- tmpNum = parseInt(digit, 10);
-
- if (shouldDouble) {
- tmpNum *= 2;
-
- if (tmpNum >= 10) {
- sum += tmpNum % 10 + 1;
- } else {
- sum += tmpNum;
- }
- } else {
- sum += tmpNum;
- }
-
- shouldDouble = !shouldDouble;
- }
-
- return !!(sum % 10 === 0 ? sanitized : false);
-}
-
-var validators = {
- ES: function ES(str) {
- assertString(str);
- var DNI = /^[0-9X-Z][0-9]{7}[TRWAGMYFPDXBNJZSQVHLCKE]$/;
- var charsValue = {
- X: 0,
- Y: 1,
- Z: 2
- };
- var controlDigits = ['T', 'R', 'W', 'A', 'G', 'M', 'Y', 'F', 'P', 'D', 'X', 'B', 'N', 'J', 'Z', 'S', 'Q', 'V', 'H', 'L', 'C', 'K', 'E']; // sanitize user input
-
- var sanitized = str.trim().toUpperCase(); // validate the data structure
-
- if (!DNI.test(sanitized)) {
- return false;
- } // validate the control digit
-
-
- var number = sanitized.slice(0, -1).replace(/[X,Y,Z]/g, function (_char) {
- return charsValue[_char];
- });
- return sanitized.endsWith(controlDigits[number % 23]);
- },
- IN: function IN(str) {
- var DNI = /^[1-9]\d{3}\s?\d{4}\s?\d{4}$/; // multiplication table
-
- var d = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 0, 6, 7, 8, 9, 5], [2, 3, 4, 0, 1, 7, 8, 9, 5, 6], [3, 4, 0, 1, 2, 8, 9, 5, 6, 7], [4, 0, 1, 2, 3, 9, 5, 6, 7, 8], [5, 9, 8, 7, 6, 0, 4, 3, 2, 1], [6, 5, 9, 8, 7, 1, 0, 4, 3, 2], [7, 6, 5, 9, 8, 2, 1, 0, 4, 3], [8, 7, 6, 5, 9, 3, 2, 1, 0, 4], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]]; // permutation table
-
- var p = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 5, 7, 6, 2, 8, 3, 0, 9, 4], [5, 8, 0, 3, 7, 9, 6, 1, 4, 2], [8, 9, 1, 6, 0, 4, 3, 5, 2, 7], [9, 4, 5, 3, 1, 2, 6, 8, 7, 0], [4, 2, 8, 6, 5, 7, 3, 9, 0, 1], [2, 7, 9, 3, 8, 0, 6, 4, 1, 5], [7, 0, 4, 6, 9, 1, 3, 2, 5, 8]]; // sanitize user input
-
- var sanitized = str.trim(); // validate the data structure
-
- if (!DNI.test(sanitized)) {
- return false;
- }
-
- var c = 0;
- var invertedArray = sanitized.replace(/\s/g, '').split('').map(Number).reverse();
- invertedArray.forEach(function (val, i) {
- c = d[c][p[i % 8][val]];
- });
- return c === 0;
- },
- IT: function IT(str) {
- if (str.length !== 9) return false;
- if (str === 'CA00000AA') return false; // https://it.wikipedia.org/wiki/Carta_d%27identit%C3%A0_elettronica_italiana
-
- return str.search(/C[A-Z][0-9]{5}[A-Z]{2}/i) > -1;
- },
- NO: function NO(str) {
- var sanitized = str.trim();
- if (isNaN(Number(sanitized))) return false;
- if (sanitized.length !== 11) return false;
- if (sanitized === '00000000000') return false; // https://no.wikipedia.org/wiki/F%C3%B8dselsnummer
-
- var f = sanitized.split('').map(Number);
- var k1 = (11 - (3 * f[0] + 7 * f[1] + 6 * f[2] + 1 * f[3] + 8 * f[4] + 9 * f[5] + 4 * f[6] + 5 * f[7] + 2 * f[8]) % 11) % 11;
- var k2 = (11 - (5 * f[0] + 4 * f[1] + 3 * f[2] + 2 * f[3] + 7 * f[4] + 6 * f[5] + 5 * f[6] + 4 * f[7] + 3 * f[8] + 2 * k1) % 11) % 11;
- if (k1 !== f[9] || k2 !== f[10]) return false;
- return true;
- },
- 'he-IL': function heIL(str) {
- var DNI = /^\d{9}$/; // sanitize user input
-
- var sanitized = str.trim(); // validate the data structure
-
- if (!DNI.test(sanitized)) {
- return false;
- }
-
- var id = sanitized;
- var sum = 0,
- incNum;
-
- for (var i = 0; i < id.length; i++) {
- incNum = Number(id[i]) * (i % 2 + 1); // Multiply number by 1 or 2
-
- sum += incNum > 9 ? incNum - 9 : incNum; // Sum the digits up and add to total
- }
-
- return sum % 10 === 0;
- },
- 'ar-TN': function arTN(str) {
- var DNI = /^\d{8}$/; // sanitize user input
-
- var sanitized = str.trim(); // validate the data structure
-
- if (!DNI.test(sanitized)) {
- return false;
- }
-
- return true;
- },
- 'zh-CN': function zhCN(str) {
- var provincesAndCities = ['11', // 北京
- '12', // 天津
- '13', // 河北
- '14', // 山西
- '15', // 内蒙古
- '21', // 辽宁
- '22', // 吉林
- '23', // 黑龙江
- '31', // 上海
- '32', // 江苏
- '33', // 浙江
- '34', // 安徽
- '35', // 福建
- '36', // 江西
- '37', // 山东
- '41', // 河南
- '42', // 湖北
- '43', // 湖南
- '44', // 广东
- '45', // 广西
- '46', // 海南
- '50', // 重庆
- '51', // 四川
- '52', // 贵州
- '53', // 云南
- '54', // 西藏
- '61', // 陕西
- '62', // 甘肃
- '63', // 青海
- '64', // 宁夏
- '65', // 新疆
- '71', // 台湾
- '81', // 香港
- '82', // 澳门
- '91' // 国外
- ];
- var powers = ['7', '9', '10', '5', '8', '4', '2', '1', '6', '3', '7', '9', '10', '5', '8', '4', '2'];
- var parityBit = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
-
- var checkAddressCode = function checkAddressCode(addressCode) {
- return provincesAndCities.includes(addressCode);
- };
-
- var checkBirthDayCode = function checkBirthDayCode(birDayCode) {
- var yyyy = parseInt(birDayCode.substring(0, 4), 10);
- var mm = parseInt(birDayCode.substring(4, 6), 10);
- var dd = parseInt(birDayCode.substring(6), 10);
- var xdata = new Date(yyyy, mm - 1, dd);
-
- if (xdata > new Date()) {
- return false; // eslint-disable-next-line max-len
- } else if (xdata.getFullYear() === yyyy && xdata.getMonth() === mm - 1 && xdata.getDate() === dd) {
- return true;
- }
-
- return false;
- };
-
- var getParityBit = function getParityBit(idCardNo) {
- var id17 = idCardNo.substring(0, 17);
- var power = 0;
-
- for (var i = 0; i < 17; i++) {
- power += parseInt(id17.charAt(i), 10) * parseInt(powers[i], 10);
- }
-
- var mod = power % 11;
- return parityBit[mod];
- };
-
- var checkParityBit = function checkParityBit(idCardNo) {
- return getParityBit(idCardNo) === idCardNo.charAt(17).toUpperCase();
- };
-
- var check15IdCardNo = function check15IdCardNo(idCardNo) {
- var check = /^[1-9]\d{7}((0[1-9])|(1[0-2]))((0[1-9])|([1-2][0-9])|(3[0-1]))\d{3}$/.test(idCardNo);
- if (!check) return false;
- var addressCode = idCardNo.substring(0, 2);
- check = checkAddressCode(addressCode);
- if (!check) return false;
- var birDayCode = "19".concat(idCardNo.substring(6, 12));
- check = checkBirthDayCode(birDayCode);
- if (!check) return false;
- return true;
- };
-
- var check18IdCardNo = function check18IdCardNo(idCardNo) {
- var check = /^[1-9]\d{5}[1-9]\d{3}((0[1-9])|(1[0-2]))((0[1-9])|([1-2][0-9])|(3[0-1]))\d{3}(\d|x|X)$/.test(idCardNo);
- if (!check) return false;
- var addressCode = idCardNo.substring(0, 2);
- check = checkAddressCode(addressCode);
- if (!check) return false;
- var birDayCode = idCardNo.substring(6, 14);
- check = checkBirthDayCode(birDayCode);
- if (!check) return false;
- return checkParityBit(idCardNo);
- };
-
- var checkIdCardNo = function checkIdCardNo(idCardNo) {
- var check = /^\d{15}|(\d{17}(\d|x|X))$/.test(idCardNo);
- if (!check) return false;
-
- if (idCardNo.length === 15) {
- return check15IdCardNo(idCardNo);
- }
-
- return check18IdCardNo(idCardNo);
- };
-
- return checkIdCardNo(str);
- },
- 'zh-TW': function zhTW(str) {
- var ALPHABET_CODES = {
- A: 10,
- B: 11,
- C: 12,
- D: 13,
- E: 14,
- F: 15,
- G: 16,
- H: 17,
- I: 34,
- J: 18,
- K: 19,
- L: 20,
- M: 21,
- N: 22,
- O: 35,
- P: 23,
- Q: 24,
- R: 25,
- S: 26,
- T: 27,
- U: 28,
- V: 29,
- W: 32,
- X: 30,
- Y: 31,
- Z: 33
- };
- var sanitized = str.trim().toUpperCase();
- if (!/^[A-Z][0-9]{9}$/.test(sanitized)) return false;
- return Array.from(sanitized).reduce(function (sum, number, index) {
- if (index === 0) {
- var code = ALPHABET_CODES[number];
- return code % 10 * 9 + Math.floor(code / 10);
- }
-
- if (index === 9) {
- return (10 - sum % 10 - Number(number)) % 10 === 0;
- }
-
- return sum + Number(number) * (9 - index);
- }, 0);
- }
-};
-function isIdentityCard(str, locale) {
- assertString(str);
-
- if (locale in validators) {
- return validators[locale](str);
- } else if (locale === 'any') {
- for (var key in validators) {
- // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
- // istanbul ignore else
- if (validators.hasOwnProperty(key)) {
- var validator = validators[key];
-
- if (validator(str)) {
- return true;
- }
- }
- }
-
- return false;
- }
-
- throw new Error("Invalid locale '".concat(locale, "'"));
-}
-
-/**
- * The most commonly used EAN standard is
- * the thirteen-digit EAN-13, while the
- * less commonly used 8-digit EAN-8 barcode was
- * introduced for use on small packages.
- * EAN consists of:
- * GS1 prefix, manufacturer code, product code and check digit
- * Reference: https://en.wikipedia.org/wiki/International_Article_Number
- */
-/**
- * Define EAN Lenghts; 8 for EAN-8; 13 for EAN-13
- * and Regular Expression for valid EANs (EAN-8, EAN-13),
- * with exact numberic matching of 8 or 13 digits [0-9]
- */
-
-var LENGTH_EAN_8 = 8;
-var validEanRegex = /^(\d{8}|\d{13})$/;
-/**
- * Get position weight given:
- * EAN length and digit index/position
- *
- * @param {number} length
- * @param {number} index
- * @return {number}
- */
-
-function getPositionWeightThroughLengthAndIndex(length, index) {
- if (length === LENGTH_EAN_8) {
- return index % 2 === 0 ? 3 : 1;
- }
-
- return index % 2 === 0 ? 1 : 3;
-}
-/**
- * Calculate EAN Check Digit
- * Reference: https://en.wikipedia.org/wiki/International_Article_Number#Calculation_of_checksum_digit
- *
- * @param {string} ean
- * @return {number}
- */
-
-
-function calculateCheckDigit(ean) {
- var checksum = ean.slice(0, -1).split('').map(function (_char, index) {
- return Number(_char) * getPositionWeightThroughLengthAndIndex(ean.length, index);
- }).reduce(function (acc, partialSum) {
- return acc + partialSum;
- }, 0);
- var remainder = 10 - checksum % 10;
- return remainder < 10 ? remainder : 0;
-}
-/**
- * Check if string is valid EAN:
- * Matches EAN-8/EAN-13 regex
- * Has valid check digit.
- *
- * @param {string} str
- * @return {boolean}
- */
-
-
-function isEAN(str) {
- assertString(str);
- var actualCheckDigit = Number(str.slice(-1));
- return validEanRegex.test(str) && actualCheckDigit === calculateCheckDigit(str);
-}
-
-var isin = /^[A-Z]{2}[0-9A-Z]{9}[0-9]$/;
-function isISIN(str) {
- assertString(str);
-
- if (!isin.test(str)) {
- return false;
- }
-
- var checksumStr = str.replace(/[A-Z]/g, function (character) {
- return parseInt(character, 36);
- });
- var sum = 0;
- var digit;
- var tmpNum;
- var shouldDouble = true;
-
- for (var i = checksumStr.length - 2; i >= 0; i--) {
- digit = checksumStr.substring(i, i + 1);
- tmpNum = parseInt(digit, 10);
-
- if (shouldDouble) {
- tmpNum *= 2;
-
- if (tmpNum >= 10) {
- sum += tmpNum + 1;
- } else {
- sum += tmpNum;
- }
- } else {
- sum += tmpNum;
- }
-
- shouldDouble = !shouldDouble;
- }
-
- return parseInt(str.substr(str.length - 1), 10) === (10000 - sum) % 10;
-}
-
-var isbn10Maybe = /^(?:[0-9]{9}X|[0-9]{10})$/;
-var isbn13Maybe = /^(?:[0-9]{13})$/;
-var factor = [1, 3];
-function isISBN(str) {
- var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
- assertString(str);
- version = String(version);
-
- if (!version) {
- return isISBN(str, 10) || isISBN(str, 13);
- }
-
- var sanitized = str.replace(/[\s-]+/g, '');
- var checksum = 0;
- var i;
-
- if (version === '10') {
- if (!isbn10Maybe.test(sanitized)) {
- return false;
- }
-
- for (i = 0; i < 9; i++) {
- checksum += (i + 1) * sanitized.charAt(i);
- }
-
- if (sanitized.charAt(9) === 'X') {
- checksum += 10 * 10;
- } else {
- checksum += 10 * sanitized.charAt(9);
- }
-
- if (checksum % 11 === 0) {
- return !!sanitized;
- }
- } else if (version === '13') {
- if (!isbn13Maybe.test(sanitized)) {
- return false;
- }
-
- for (i = 0; i < 12; i++) {
- checksum += factor[i % 2] * sanitized.charAt(i);
- }
-
- if (sanitized.charAt(12) - (10 - checksum % 10) % 10 === 0) {
- return !!sanitized;
- }
- }
-
- return false;
-}
-
-var issn = '^\\d{4}-?\\d{3}[\\dX]$';
-function isISSN(str) {
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- assertString(str);
- var testIssn = issn;
- testIssn = options.require_hyphen ? testIssn.replace('?', '') : testIssn;
- testIssn = options.case_sensitive ? new RegExp(testIssn) : new RegExp(testIssn, 'i');
-
- if (!testIssn.test(str)) {
- return false;
- }
-
- var digits = str.replace('-', '').toUpperCase();
- var checksum = 0;
-
- for (var i = 0; i < digits.length; i++) {
- var digit = digits[i];
- checksum += (digit === 'X' ? 10 : +digit) * (8 - i);
- }
-
- return checksum % 11 === 0;
-}
-
-/**
- * Algorithmic validation functions
- * May be used as is or implemented in the workflow of other validators.
- */
-
-/*
- * ISO 7064 validation function
- * Called with a string of numbers (incl. check digit)
- * to validate according to ISO 7064 (MOD 11, 10).
- */
-function iso7064Check(str) {
- var checkvalue = 10;
-
- for (var i = 0; i < str.length - 1; i++) {
- checkvalue = (parseInt(str[i], 10) + checkvalue) % 10 === 0 ? 10 * 2 % 11 : (parseInt(str[i], 10) + checkvalue) % 10 * 2 % 11;
- }
-
- checkvalue = checkvalue === 1 ? 0 : 11 - checkvalue;
- return checkvalue === parseInt(str[10], 10);
-}
-/*
- * Luhn (mod 10) validation function
- * Called with a string of numbers (incl. check digit)
- * to validate according to the Luhn algorithm.
- */
-
-function luhnCheck(str) {
- var checksum = 0;
- var second = false;
-
- for (var i = str.length - 1; i >= 0; i--) {
- if (second) {
- var product = parseInt(str[i], 10) * 2;
-
- if (product > 9) {
- // sum digits of product and add to checksum
- checksum += product.toString().split('').map(function (a) {
- return parseInt(a, 10);
- }).reduce(function (a, b) {
- return a + b;
- }, 0);
- } else {
- checksum += product;
- }
- } else {
- checksum += parseInt(str[i], 10);
- }
-
- second = !second;
- }
-
- return checksum % 10 === 0;
-}
-/*
- * Reverse TIN multiplication and summation helper function
- * Called with an array of single-digit integers and a base multiplier
- * to calculate the sum of the digits multiplied in reverse.
- * Normally used in variations of MOD 11 algorithmic checks.
- */
-
-function reverseMultiplyAndSum(digits, base) {
- var total = 0;
-
- for (var i = 0; i < digits.length; i++) {
- total += digits[i] * (base - i);
- }
-
- return total;
-}
-/*
- * Verhoeff validation helper function
- * Called with a string of numbers
- * to validate according to the Verhoeff algorithm.
- */
-
-function verhoeffCheck(str) {
- var d_table = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 0, 6, 7, 8, 9, 5], [2, 3, 4, 0, 1, 7, 8, 9, 5, 6], [3, 4, 0, 1, 2, 8, 9, 5, 6, 7], [4, 0, 1, 2, 3, 9, 5, 6, 7, 8], [5, 9, 8, 7, 6, 0, 4, 3, 2, 1], [6, 5, 9, 8, 7, 1, 0, 4, 3, 2], [7, 6, 5, 9, 8, 2, 1, 0, 4, 3], [8, 7, 6, 5, 9, 3, 2, 1, 0, 4], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]];
- var p_table = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 5, 7, 6, 2, 8, 3, 0, 9, 4], [5, 8, 0, 3, 7, 9, 6, 1, 4, 2], [8, 9, 1, 6, 0, 4, 3, 5, 2, 7], [9, 4, 5, 3, 1, 2, 6, 8, 7, 0], [4, 2, 8, 6, 5, 7, 3, 9, 0, 1], [2, 7, 9, 3, 8, 0, 6, 4, 1, 5], [7, 0, 4, 6, 9, 1, 3, 2, 5, 8]]; // Copy (to prevent replacement) and reverse
-
- var str_copy = str.split('').reverse().join('');
- var checksum = 0;
-
- for (var i = 0; i < str_copy.length; i++) {
- checksum = d_table[checksum][p_table[i % 8][parseInt(str_copy[i], 10)]];
- }
-
- return checksum === 0;
-}
-
-/**
- * TIN Validation
- * Validates Tax Identification Numbers (TINs) from the US, EU member states and the United Kingdom.
- *
- * EU-UK:
- * National TIN validity is calculated using public algorithms as made available by DG TAXUD.
- *
- * See `https://ec.europa.eu/taxation_customs/tin/specs/FS-TIN%20Algorithms-Public.docx` for more information.
- *
- * US:
- * An Employer Identification Number (EIN), also known as a Federal Tax Identification Number,
- * is used to identify a business entity.
- *
- * NOTES:
- * - Prefix 47 is being reserved for future use
- * - Prefixes 26, 27, 45, 46 and 47 were previously assigned by the Philadelphia campus.
- *
- * See `http://www.irs.gov/Businesses/Small-Businesses-&-Self-Employed/How-EINs-are-Assigned-and-Valid-EIN-Prefixes`
- * for more information.
- */
-// Locale functions
-
-/*
- * bg-BG validation function
- * (Edinen graždanski nomer (EGN/ЕГН), persons only)
- * Checks if birth date (first six digits) is valid and calculates check (last) digit
- */
-
-function bgBgCheck(tin) {
- // Extract full year, normalize month and check birth date validity
- var century_year = tin.slice(0, 2);
- var month = parseInt(tin.slice(2, 4), 10);
-
- if (month > 40) {
- month -= 40;
- century_year = "20".concat(century_year);
- } else if (month > 20) {
- month -= 20;
- century_year = "18".concat(century_year);
- } else {
- century_year = "19".concat(century_year);
- }
-
- if (month < 10) {
- month = "0".concat(month);
- }
-
- var date = "".concat(century_year, "/").concat(month, "/").concat(tin.slice(4, 6));
-
- if (!isDate(date, 'YYYY/MM/DD')) {
- return false;
- } // split digits into an array for further processing
-
-
- var digits = tin.split('').map(function (a) {
- return parseInt(a, 10);
- }); // Calculate checksum by multiplying digits with fixed values
-
- var multip_lookup = [2, 4, 8, 5, 10, 9, 7, 3, 6];
- var checksum = 0;
-
- for (var i = 0; i < multip_lookup.length; i++) {
- checksum += digits[i] * multip_lookup[i];
- }
-
- checksum = checksum % 11 === 10 ? 0 : checksum % 11;
- return checksum === digits[9];
-}
-/*
- * cs-CZ validation function
- * (Rodné číslo (RČ), persons only)
- * Checks if birth date (first six digits) is valid and divisibility by 11
- * Material not in DG TAXUD document sourced from:
- * -`https://lorenc.info/3MA381/overeni-spravnosti-rodneho-cisla.htm`
- * -`https://www.mvcr.cz/clanek/rady-a-sluzby-dokumenty-rodne-cislo.aspx`
- */
-
-
-function csCzCheck(tin) {
- tin = tin.replace(/\W/, ''); // Extract full year from TIN length
-
- var full_year = parseInt(tin.slice(0, 2), 10);
-
- if (tin.length === 10) {
- if (full_year < 54) {
- full_year = "20".concat(full_year);
- } else {
- full_year = "19".concat(full_year);
- }
- } else {
- if (tin.slice(6) === '000') {
- return false;
- } // Three-zero serial not assigned before 1954
-
-
- if (full_year < 54) {
- full_year = "19".concat(full_year);
- } else {
- return false; // No 18XX years seen in any of the resources
- }
- } // Add missing zero if needed
-
-
- if (full_year.length === 3) {
- full_year = [full_year.slice(0, 2), '0', full_year.slice(2)].join('');
- } // Extract month from TIN and normalize
-
-
- var month = parseInt(tin.slice(2, 4), 10);
-
- if (month > 50) {
- month -= 50;
- }
-
- if (month > 20) {
- // Month-plus-twenty was only introduced in 2004
- if (parseInt(full_year, 10) < 2004) {
- return false;
- }
-
- month -= 20;
- }
-
- if (month < 10) {
- month = "0".concat(month);
- } // Check date validity
-
-
- var date = "".concat(full_year, "/").concat(month, "/").concat(tin.slice(4, 6));
-
- if (!isDate(date, 'YYYY/MM/DD')) {
- return false;
- } // Verify divisibility by 11
-
-
- if (tin.length === 10) {
- if (parseInt(tin, 10) % 11 !== 0) {
- // Some numbers up to and including 1985 are still valid if
- // check (last) digit equals 0 and modulo of first 9 digits equals 10
- var checkdigit = parseInt(tin.slice(0, 9), 10) % 11;
-
- if (parseInt(full_year, 10) < 1986 && checkdigit === 10) {
- if (parseInt(tin.slice(9), 10) !== 0) {
- return false;
- }
- } else {
- return false;
- }
- }
- }
-
- return true;
-}
-/*
- * de-AT validation function
- * (Abgabenkontonummer, persons/entities)
- * Verify TIN validity by calling luhnCheck()
- */
-
-
-function deAtCheck(tin) {
- return luhnCheck(tin);
-}
-/*
- * de-DE validation function
- * (Steueridentifikationsnummer (Steuer-IdNr.), persons only)
- * Tests for single duplicate/triplicate value, then calculates ISO 7064 check (last) digit
- * Partial implementation of spec (same result with both algorithms always)
- */
-
-
-function deDeCheck(tin) {
- // Split digits into an array for further processing
- var digits = tin.split('').map(function (a) {
- return parseInt(a, 10);
- }); // Fill array with strings of number positions
-
- var occurences = [];
-
- for (var i = 0; i < digits.length - 1; i++) {
- occurences.push('');
-
- for (var j = 0; j < digits.length - 1; j++) {
- if (digits[i] === digits[j]) {
- occurences[i] += j;
- }
- }
- } // Remove digits with one occurence and test for only one duplicate/triplicate
-
-
- occurences = occurences.filter(function (a) {
- return a.length > 1;
- });
-
- if (occurences.length !== 2 && occurences.length !== 3) {
- return false;
- } // In case of triplicate value only two digits are allowed next to each other
-
-
- if (occurences[0].length === 3) {
- var trip_locations = occurences[0].split('').map(function (a) {
- return parseInt(a, 10);
- });
- var recurrent = 0; // Amount of neighbour occurences
-
- for (var _i = 0; _i < trip_locations.length - 1; _i++) {
- if (trip_locations[_i] + 1 === trip_locations[_i + 1]) {
- recurrent += 1;
- }
- }
-
- if (recurrent === 2) {
- return false;
- }
- }
-
- return iso7064Check(tin);
-}
-/*
- * dk-DK validation function
- * (CPR-nummer (personnummer), persons only)
- * Checks if birth date (first six digits) is valid and assigned to century (seventh) digit,
- * and calculates check (last) digit
- */
-
-
-function dkDkCheck(tin) {
- tin = tin.replace(/\W/, ''); // Extract year, check if valid for given century digit and add century
-
- var year = parseInt(tin.slice(4, 6), 10);
- var century_digit = tin.slice(6, 7);
-
- switch (century_digit) {
- case '0':
- case '1':
- case '2':
- case '3':
- year = "19".concat(year);
- break;
-
- case '4':
- case '9':
- if (year < 37) {
- year = "20".concat(year);
- } else {
- year = "19".concat(year);
- }
-
- break;
-
- default:
- if (year < 37) {
- year = "20".concat(year);
- } else if (year > 58) {
- year = "18".concat(year);
- } else {
- return false;
- }
-
- break;
- } // Add missing zero if needed
-
-
- if (year.length === 3) {
- year = [year.slice(0, 2), '0', year.slice(2)].join('');
- } // Check date validity
-
-
- var date = "".concat(year, "/").concat(tin.slice(2, 4), "/").concat(tin.slice(0, 2));
-
- if (!isDate(date, 'YYYY/MM/DD')) {
- return false;
- } // Split digits into an array for further processing
-
-
- var digits = tin.split('').map(function (a) {
- return parseInt(a, 10);
- });
- var checksum = 0;
- var weight = 4; // Multiply by weight and add to checksum
-
- for (var i = 0; i < 9; i++) {
- checksum += digits[i] * weight;
- weight -= 1;
-
- if (weight === 1) {
- weight = 7;
- }
- }
-
- checksum %= 11;
-
- if (checksum === 1) {
- return false;
- }
-
- return checksum === 0 ? digits[9] === 0 : digits[9] === 11 - checksum;
-}
-/*
- * el-CY validation function
- * (Arithmos Forologikou Mitroou (AFM/ΑΦΜ), persons only)
- * Verify TIN validity by calculating ASCII value of check (last) character
- */
-
-
-function elCyCheck(tin) {
- // split digits into an array for further processing
- var digits = tin.slice(0, 8).split('').map(function (a) {
- return parseInt(a, 10);
- });
- var checksum = 0; // add digits in even places
-
- for (var i = 1; i < digits.length; i += 2) {
- checksum += digits[i];
- } // add digits in odd places
-
-
- for (var _i2 = 0; _i2 < digits.length; _i2 += 2) {
- if (digits[_i2] < 2) {
- checksum += 1 - digits[_i2];
- } else {
- checksum += 2 * (digits[_i2] - 2) + 5;
-
- if (digits[_i2] > 4) {
- checksum += 2;
- }
- }
- }
-
- return String.fromCharCode(checksum % 26 + 65) === tin.charAt(8);
-}
-/*
- * el-GR validation function
- * (Arithmos Forologikou Mitroou (AFM/ΑΦΜ), persons/entities)
- * Verify TIN validity by calculating check (last) digit
- * Algorithm not in DG TAXUD document- sourced from:
- * - `http://epixeirisi.gr/%CE%9A%CE%A1%CE%99%CE%A3%CE%99%CE%9C%CE%91-%CE%98%CE%95%CE%9C%CE%91%CE%A4%CE%91-%CE%A6%CE%9F%CE%A1%CE%9F%CE%9B%CE%9F%CE%93%CE%99%CE%91%CE%A3-%CE%9A%CE%91%CE%99-%CE%9B%CE%9F%CE%93%CE%99%CE%A3%CE%A4%CE%99%CE%9A%CE%97%CE%A3/23791/%CE%91%CF%81%CE%B9%CE%B8%CE%BC%CF%8C%CF%82-%CE%A6%CE%BF%CF%81%CE%BF%CE%BB%CE%BF%CE%B3%CE%B9%CE%BA%CE%BF%CF%8D-%CE%9C%CE%B7%CF%84%CF%81%CF%8E%CE%BF%CF%85`
- */
-
-
-function elGrCheck(tin) {
- // split digits into an array for further processing
- var digits = tin.split('').map(function (a) {
- return parseInt(a, 10);
- });
- var checksum = 0;
-
- for (var i = 0; i < 8; i++) {
- checksum += digits[i] * Math.pow(2, 8 - i);
- }
-
- return checksum % 11 === digits[8];
-}
-/*
- * en-GB validation function (should go here if needed)
- * (National Insurance Number (NINO) or Unique Taxpayer Reference (UTR),
- * persons/entities respectively)
- */
-
-/*
- * en-IE validation function
- * (Personal Public Service Number (PPS No), persons only)
- * Verify TIN validity by calculating check (second to last) character
- */
-
-
-function enIeCheck(tin) {
- var checksum = reverseMultiplyAndSum(tin.split('').slice(0, 7).map(function (a) {
- return parseInt(a, 10);
- }), 8);
-
- if (tin.length === 9 && tin[8] !== 'W') {
- checksum += (tin[8].charCodeAt(0) - 64) * 9;
- }
-
- checksum %= 23;
-
- if (checksum === 0) {
- return tin[7].toUpperCase() === 'W';
- }
-
- return tin[7].toUpperCase() === String.fromCharCode(64 + checksum);
-} // Valid US IRS campus prefixes
-
-
-var enUsCampusPrefix = {
- andover: ['10', '12'],
- atlanta: ['60', '67'],
- austin: ['50', '53'],
- brookhaven: ['01', '02', '03', '04', '05', '06', '11', '13', '14', '16', '21', '22', '23', '25', '34', '51', '52', '54', '55', '56', '57', '58', '59', '65'],
- cincinnati: ['30', '32', '35', '36', '37', '38', '61'],
- fresno: ['15', '24'],
- internet: ['20', '26', '27', '45', '46', '47'],
- kansas: ['40', '44'],
- memphis: ['94', '95'],
- ogden: ['80', '90'],
- philadelphia: ['33', '39', '41', '42', '43', '46', '48', '62', '63', '64', '66', '68', '71', '72', '73', '74', '75', '76', '77', '81', '82', '83', '84', '85', '86', '87', '88', '91', '92', '93', '98', '99'],
- sba: ['31']
-}; // Return an array of all US IRS campus prefixes
-
-function enUsGetPrefixes() {
- var prefixes = [];
-
- for (var location in enUsCampusPrefix) {
- // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
- // istanbul ignore else
- if (enUsCampusPrefix.hasOwnProperty(location)) {
- prefixes.push.apply(prefixes, _toConsumableArray(enUsCampusPrefix[location]));
- }
- }
-
- return prefixes;
-}
-/*
- * en-US validation function
- * Verify that the TIN starts with a valid IRS campus prefix
- */
-
-
-function enUsCheck(tin) {
- return enUsGetPrefixes().indexOf(tin.substr(0, 2)) !== -1;
-}
-/*
- * es-ES validation function
- * (Documento Nacional de Identidad (DNI)
- * or Número de Identificación de Extranjero (NIE), persons only)
- * Verify TIN validity by calculating check (last) character
- */
-
-
-function esEsCheck(tin) {
- // Split characters into an array for further processing
- var chars = tin.toUpperCase().split(''); // Replace initial letter if needed
-
- if (isNaN(parseInt(chars[0], 10)) && chars.length > 1) {
- var lead_replace = 0;
-
- switch (chars[0]) {
- case 'Y':
- lead_replace = 1;
- break;
-
- case 'Z':
- lead_replace = 2;
- break;
-
- default:
- }
-
- chars.splice(0, 1, lead_replace); // Fill with zeros if smaller than proper
- } else {
- while (chars.length < 9) {
- chars.unshift(0);
- }
- } // Calculate checksum and check according to lookup
-
-
- var lookup = ['T', 'R', 'W', 'A', 'G', 'M', 'Y', 'F', 'P', 'D', 'X', 'B', 'N', 'J', 'Z', 'S', 'Q', 'V', 'H', 'L', 'C', 'K', 'E'];
- chars = chars.join('');
- var checksum = parseInt(chars.slice(0, 8), 10) % 23;
- return chars[8] === lookup[checksum];
-}
-/*
- * et-EE validation function
- * (Isikukood (IK), persons only)
- * Checks if birth date (century digit and six following) is valid and calculates check (last) digit
- * Material not in DG TAXUD document sourced from:
- * - `https://www.oecd.org/tax/automatic-exchange/crs-implementation-and-assistance/tax-identification-numbers/Estonia-TIN.pdf`
- */
-
-
-function etEeCheck(tin) {
- // Extract year and add century
- var full_year = tin.slice(1, 3);
- var century_digit = tin.slice(0, 1);
-
- switch (century_digit) {
- case '1':
- case '2':
- full_year = "18".concat(full_year);
- break;
-
- case '3':
- case '4':
- full_year = "19".concat(full_year);
- break;
-
- default:
- full_year = "20".concat(full_year);
- break;
- } // Check date validity
-
-
- var date = "".concat(full_year, "/").concat(tin.slice(3, 5), "/").concat(tin.slice(5, 7));
-
- if (!isDate(date, 'YYYY/MM/DD')) {
- return false;
- } // Split digits into an array for further processing
-
-
- var digits = tin.split('').map(function (a) {
- return parseInt(a, 10);
- });
- var checksum = 0;
- var weight = 1; // Multiply by weight and add to checksum
-
- for (var i = 0; i < 10; i++) {
- checksum += digits[i] * weight;
- weight += 1;
-
- if (weight === 10) {
- weight = 1;
- }
- } // Do again if modulo 11 of checksum is 10
-
-
- if (checksum % 11 === 10) {
- checksum = 0;
- weight = 3;
-
- for (var _i3 = 0; _i3 < 10; _i3++) {
- checksum += digits[_i3] * weight;
- weight += 1;
-
- if (weight === 10) {
- weight = 1;
- }
- }
-
- if (checksum % 11 === 10) {
- return digits[10] === 0;
- }
- }
-
- return checksum % 11 === digits[10];
-}
-/*
- * fi-FI validation function
- * (Henkilötunnus (HETU), persons only)
- * Checks if birth date (first six digits plus century symbol) is valid
- * and calculates check (last) digit
- */
-
-
-function fiFiCheck(tin) {
- // Extract year and add century
- var full_year = tin.slice(4, 6);
- var century_symbol = tin.slice(6, 7);
-
- switch (century_symbol) {
- case '+':
- full_year = "18".concat(full_year);
- break;
-
- case '-':
- full_year = "19".concat(full_year);
- break;
-
- default:
- full_year = "20".concat(full_year);
- break;
- } // Check date validity
-
-
- var date = "".concat(full_year, "/").concat(tin.slice(2, 4), "/").concat(tin.slice(0, 2));
-
- if (!isDate(date, 'YYYY/MM/DD')) {
- return false;
- } // Calculate check character
-
-
- var checksum = parseInt(tin.slice(0, 6) + tin.slice(7, 10), 10) % 31;
-
- if (checksum < 10) {
- return checksum === parseInt(tin.slice(10), 10);
- }
-
- checksum -= 10;
- var letters_lookup = ['A', 'B', 'C', 'D', 'E', 'F', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y'];
- return letters_lookup[checksum] === tin.slice(10);
-}
-/*
- * fr/nl-BE validation function
- * (Numéro national (N.N.), persons only)
- * Checks if birth date (first six digits) is valid and calculates check (last two) digits
- */
-
-
-function frBeCheck(tin) {
- // Zero month/day value is acceptable
- if (tin.slice(2, 4) !== '00' || tin.slice(4, 6) !== '00') {
- // Extract date from first six digits of TIN
- var date = "".concat(tin.slice(0, 2), "/").concat(tin.slice(2, 4), "/").concat(tin.slice(4, 6));
-
- if (!isDate(date, 'YY/MM/DD')) {
- return false;
- }
- }
-
- var checksum = 97 - parseInt(tin.slice(0, 9), 10) % 97;
- var checkdigits = parseInt(tin.slice(9, 11), 10);
-
- if (checksum !== checkdigits) {
- checksum = 97 - parseInt("2".concat(tin.slice(0, 9)), 10) % 97;
-
- if (checksum !== checkdigits) {
- return false;
- }
- }
-
- return true;
-}
-/*
- * fr-FR validation function
- * (Numéro fiscal de référence (numéro SPI), persons only)
- * Verify TIN validity by calculating check (last three) digits
- */
-
-
-function frFrCheck(tin) {
- tin = tin.replace(/\s/g, '');
- var checksum = parseInt(tin.slice(0, 10), 10) % 511;
- var checkdigits = parseInt(tin.slice(10, 13), 10);
- return checksum === checkdigits;
-}
-/*
- * fr/lb-LU validation function
- * (numéro d’identification personnelle, persons only)
- * Verify birth date validity and run Luhn and Verhoeff checks
- */
-
-
-function frLuCheck(tin) {
- // Extract date and check validity
- var date = "".concat(tin.slice(0, 4), "/").concat(tin.slice(4, 6), "/").concat(tin.slice(6, 8));
-
- if (!isDate(date, 'YYYY/MM/DD')) {
- return false;
- } // Run Luhn check
-
-
- if (!luhnCheck(tin.slice(0, 12))) {
- return false;
- } // Remove Luhn check digit and run Verhoeff check
-
-
- return verhoeffCheck("".concat(tin.slice(0, 11)).concat(tin[12]));
-}
-/*
- * hr-HR validation function
- * (Osobni identifikacijski broj (OIB), persons/entities)
- * Verify TIN validity by calling iso7064Check(digits)
- */
-
-
-function hrHrCheck(tin) {
- return iso7064Check(tin);
-}
-/*
- * hu-HU validation function
- * (Adóazonosító jel, persons only)
- * Verify TIN validity by calculating check (last) digit
- */
-
-
-function huHuCheck(tin) {
- // split digits into an array for further processing
- var digits = tin.split('').map(function (a) {
- return parseInt(a, 10);
- });
- var checksum = 8;
-
- for (var i = 1; i < 9; i++) {
- checksum += digits[i] * (i + 1);
- }
-
- return checksum % 11 === digits[9];
-}
-/*
- * lt-LT validation function (should go here if needed)
- * (Asmens kodas, persons/entities respectively)
- * Current validation check is alias of etEeCheck- same format applies
- */
-
-/*
- * it-IT first/last name validity check
- * Accepts it-IT TIN-encoded names as a three-element character array and checks their validity
- * Due to lack of clarity between resources ("Are only Italian consonants used?
- * What happens if a person has X in their name?" etc.) only two test conditions
- * have been implemented:
- * Vowels may only be followed by other vowels or an X character
- * and X characters after vowels may only be followed by other X characters.
- */
-
-
-function itItNameCheck(name) {
- // true at the first occurence of a vowel
- var vowelflag = false; // true at the first occurence of an X AFTER vowel
- // (to properly handle last names with X as consonant)
-
- var xflag = false;
-
- for (var i = 0; i < 3; i++) {
- if (!vowelflag && /[AEIOU]/.test(name[i])) {
- vowelflag = true;
- } else if (!xflag && vowelflag && name[i] === 'X') {
- xflag = true;
- } else if (i > 0) {
- if (vowelflag && !xflag) {
- if (!/[AEIOU]/.test(name[i])) {
- return false;
- }
- }
-
- if (xflag) {
- if (!/X/.test(name[i])) {
- return false;
- }
- }
- }
- }
-
- return true;
-}
-/*
- * it-IT validation function
- * (Codice fiscale (TIN-IT), persons only)
- * Verify name, birth date and codice catastale validity
- * and calculate check character.
- * Material not in DG-TAXUD document sourced from:
- * `https://en.wikipedia.org/wiki/Italian_fiscal_code`
- */
-
-
-function itItCheck(tin) {
- // Capitalize and split characters into an array for further processing
- var chars = tin.toUpperCase().split(''); // Check first and last name validity calling itItNameCheck()
-
- if (!itItNameCheck(chars.slice(0, 3))) {
- return false;
- }
-
- if (!itItNameCheck(chars.slice(3, 6))) {
- return false;
- } // Convert letters in number spaces back to numbers if any
-
-
- var number_locations = [6, 7, 9, 10, 12, 13, 14];
- var number_replace = {
- L: '0',
- M: '1',
- N: '2',
- P: '3',
- Q: '4',
- R: '5',
- S: '6',
- T: '7',
- U: '8',
- V: '9'
- };
-
- for (var _i4 = 0, _number_locations = number_locations; _i4 < _number_locations.length; _i4++) {
- var i = _number_locations[_i4];
-
- if (chars[i] in number_replace) {
- chars.splice(i, 1, number_replace[chars[i]]);
- }
- } // Extract month and day, and check date validity
-
-
- var month_replace = {
- A: '01',
- B: '02',
- C: '03',
- D: '04',
- E: '05',
- H: '06',
- L: '07',
- M: '08',
- P: '09',
- R: '10',
- S: '11',
- T: '12'
- };
- var month = month_replace[chars[8]];
- var day = parseInt(chars[9] + chars[10], 10);
-
- if (day > 40) {
- day -= 40;
- }
-
- if (day < 10) {
- day = "0".concat(day);
- }
-
- var date = "".concat(chars[6]).concat(chars[7], "/").concat(month, "/").concat(day);
-
- if (!isDate(date, 'YY/MM/DD')) {
- return false;
- } // Calculate check character by adding up even and odd characters as numbers
-
-
- var checksum = 0;
-
- for (var _i5 = 1; _i5 < chars.length - 1; _i5 += 2) {
- var char_to_int = parseInt(chars[_i5], 10);
-
- if (isNaN(char_to_int)) {
- char_to_int = chars[_i5].charCodeAt(0) - 65;
- }
-
- checksum += char_to_int;
- }
-
- var odd_convert = {
- // Maps of characters at odd places
- A: 1,
- B: 0,
- C: 5,
- D: 7,
- E: 9,
- F: 13,
- G: 15,
- H: 17,
- I: 19,
- J: 21,
- K: 2,
- L: 4,
- M: 18,
- N: 20,
- O: 11,
- P: 3,
- Q: 6,
- R: 8,
- S: 12,
- T: 14,
- U: 16,
- V: 10,
- W: 22,
- X: 25,
- Y: 24,
- Z: 23,
- 0: 1,
- 1: 0
- };
-
- for (var _i6 = 0; _i6 < chars.length - 1; _i6 += 2) {
- var _char_to_int = 0;
-
- if (chars[_i6] in odd_convert) {
- _char_to_int = odd_convert[chars[_i6]];
- } else {
- var multiplier = parseInt(chars[_i6], 10);
- _char_to_int = 2 * multiplier + 1;
-
- if (multiplier > 4) {
- _char_to_int += 2;
- }
- }
-
- checksum += _char_to_int;
- }
-
- if (String.fromCharCode(65 + checksum % 26) !== chars[15]) {
- return false;
- }
-
- return true;
-}
-/*
- * lv-LV validation function
- * (Personas kods (PK), persons only)
- * Check validity of birth date and calculate check (last) digit
- * Support only for old format numbers (not starting with '32', issued before 2017/07/01)
- * Material not in DG TAXUD document sourced from:
- * `https://boot.ritakafija.lv/forums/index.php?/topic/88314-personas-koda-algoritms-%C4%8Deksumma/`
- */
-
-
-function lvLvCheck(tin) {
- tin = tin.replace(/\W/, ''); // Extract date from TIN
-
- var day = tin.slice(0, 2);
-
- if (day !== '32') {
- // No date/checksum check if new format
- var month = tin.slice(2, 4);
-
- if (month !== '00') {
- // No date check if unknown month
- var full_year = tin.slice(4, 6);
-
- switch (tin[6]) {
- case '0':
- full_year = "18".concat(full_year);
- break;
-
- case '1':
- full_year = "19".concat(full_year);
- break;
-
- default:
- full_year = "20".concat(full_year);
- break;
- } // Check date validity
-
-
- var date = "".concat(full_year, "/").concat(tin.slice(2, 4), "/").concat(day);
-
- if (!isDate(date, 'YYYY/MM/DD')) {
- return false;
- }
- } // Calculate check digit
-
-
- var checksum = 1101;
- var multip_lookup = [1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
-
- for (var i = 0; i < tin.length - 1; i++) {
- checksum -= parseInt(tin[i], 10) * multip_lookup[i];
- }
-
- return parseInt(tin[10], 10) === checksum % 11;
- }
-
- return true;
-}
-/*
- * mt-MT validation function
- * (Identity Card Number or Unique Taxpayer Reference, persons/entities)
- * Verify Identity Card Number structure (no other tests found)
- */
-
-
-function mtMtCheck(tin) {
- if (tin.length !== 9) {
- // No tests for UTR
- var chars = tin.toUpperCase().split(''); // Fill with zeros if smaller than proper
-
- while (chars.length < 8) {
- chars.unshift(0);
- } // Validate format according to last character
-
-
- switch (tin[7]) {
- case 'A':
- case 'P':
- if (parseInt(chars[6], 10) === 0) {
- return false;
- }
-
- break;
-
- default:
- {
- var first_part = parseInt(chars.join('').slice(0, 5), 10);
-
- if (first_part > 32000) {
- return false;
- }
-
- var second_part = parseInt(chars.join('').slice(5, 7), 10);
-
- if (first_part === second_part) {
- return false;
- }
- }
- }
- }
-
- return true;
-}
-/*
- * nl-NL validation function
- * (Burgerservicenummer (BSN) or Rechtspersonen Samenwerkingsverbanden Informatie Nummer (RSIN),
- * persons/entities respectively)
- * Verify TIN validity by calculating check (last) digit (variant of MOD 11)
- */
-
-
-function nlNlCheck(tin) {
- return reverseMultiplyAndSum(tin.split('').slice(0, 8).map(function (a) {
- return parseInt(a, 10);
- }), 9) % 11 === parseInt(tin[8], 10);
-}
-/*
- * pl-PL validation function
- * (Powszechny Elektroniczny System Ewidencji Ludności (PESEL)
- * or Numer identyfikacji podatkowej (NIP), persons/entities)
- * Verify TIN validity by validating birth date (PESEL) and calculating check (last) digit
- */
-
-
-function plPlCheck(tin) {
- // NIP
- if (tin.length === 10) {
- // Calculate last digit by multiplying with lookup
- var lookup = [6, 5, 7, 2, 3, 4, 5, 6, 7];
- var _checksum = 0;
-
- for (var i = 0; i < lookup.length; i++) {
- _checksum += parseInt(tin[i], 10) * lookup[i];
- }
-
- _checksum %= 11;
-
- if (_checksum === 10) {
- return false;
- }
-
- return _checksum === parseInt(tin[9], 10);
- } // PESEL
- // Extract full year using month
-
-
- var full_year = tin.slice(0, 2);
- var month = parseInt(tin.slice(2, 4), 10);
-
- if (month > 80) {
- full_year = "18".concat(full_year);
- month -= 80;
- } else if (month > 60) {
- full_year = "22".concat(full_year);
- month -= 60;
- } else if (month > 40) {
- full_year = "21".concat(full_year);
- month -= 40;
- } else if (month > 20) {
- full_year = "20".concat(full_year);
- month -= 20;
- } else {
- full_year = "19".concat(full_year);
- } // Add leading zero to month if needed
-
-
- if (month < 10) {
- month = "0".concat(month);
- } // Check date validity
-
-
- var date = "".concat(full_year, "/").concat(month, "/").concat(tin.slice(4, 6));
-
- if (!isDate(date, 'YYYY/MM/DD')) {
- return false;
- } // Calculate last digit by mulitplying with odd one-digit numbers except 5
-
-
- var checksum = 0;
- var multiplier = 1;
-
- for (var _i7 = 0; _i7 < tin.length - 1; _i7++) {
- checksum += parseInt(tin[_i7], 10) * multiplier % 10;
- multiplier += 2;
-
- if (multiplier > 10) {
- multiplier = 1;
- } else if (multiplier === 5) {
- multiplier += 2;
- }
- }
-
- checksum = 10 - checksum % 10;
- return checksum === parseInt(tin[10], 10);
-}
-/*
- * pt-PT validation function
- * (Número de identificação fiscal (NIF), persons/entities)
- * Verify TIN validity by calculating check (last) digit (variant of MOD 11)
- */
-
-
-function ptPtCheck(tin) {
- var checksum = 11 - reverseMultiplyAndSum(tin.split('').slice(0, 8).map(function (a) {
- return parseInt(a, 10);
- }), 9) % 11;
-
- if (checksum > 9) {
- return parseInt(tin[8], 10) === 0;
- }
-
- return checksum === parseInt(tin[8], 10);
-}
-/*
- * ro-RO validation function
- * (Cod Numeric Personal (CNP) or Cod de înregistrare fiscală (CIF),
- * persons only)
- * Verify CNP validity by calculating check (last) digit (test not found for CIF)
- * Material not in DG TAXUD document sourced from:
- * `https://en.wikipedia.org/wiki/National_identification_number#Romania`
- */
-
-
-function roRoCheck(tin) {
- if (tin.slice(0, 4) !== '9000') {
- // No test found for this format
- // Extract full year using century digit if possible
- var full_year = tin.slice(1, 3);
-
- switch (tin[0]) {
- case '1':
- case '2':
- full_year = "19".concat(full_year);
- break;
-
- case '3':
- case '4':
- full_year = "18".concat(full_year);
- break;
-
- case '5':
- case '6':
- full_year = "20".concat(full_year);
- break;
-
- default:
- } // Check date validity
-
-
- var date = "".concat(full_year, "/").concat(tin.slice(3, 5), "/").concat(tin.slice(5, 7));
-
- if (date.length === 8) {
- if (!isDate(date, 'YY/MM/DD')) {
- return false;
- }
- } else if (!isDate(date, 'YYYY/MM/DD')) {
- return false;
- } // Calculate check digit
-
-
- var digits = tin.split('').map(function (a) {
- return parseInt(a, 10);
- });
- var multipliers = [2, 7, 9, 1, 4, 6, 3, 5, 8, 2, 7, 9];
- var checksum = 0;
-
- for (var i = 0; i < multipliers.length; i++) {
- checksum += digits[i] * multipliers[i];
- }
-
- if (checksum % 11 === 10) {
- return digits[12] === 1;
- }
-
- return digits[12] === checksum % 11;
- }
-
- return true;
-}
-/*
- * sk-SK validation function
- * (Rodné číslo (RČ) or bezvýznamové identifikačné číslo (BIČ), persons only)
- * Checks validity of pre-1954 birth numbers (rodné číslo) only
- * Due to the introduction of the pseudo-random BIČ it is not possible to test
- * post-1954 birth numbers without knowing whether they are BIČ or RČ beforehand
- */
-
-
-function skSkCheck(tin) {
- if (tin.length === 9) {
- tin = tin.replace(/\W/, '');
-
- if (tin.slice(6) === '000') {
- return false;
- } // Three-zero serial not assigned before 1954
- // Extract full year from TIN length
-
-
- var full_year = parseInt(tin.slice(0, 2), 10);
-
- if (full_year > 53) {
- return false;
- }
-
- if (full_year < 10) {
- full_year = "190".concat(full_year);
- } else {
- full_year = "19".concat(full_year);
- } // Extract month from TIN and normalize
-
-
- var month = parseInt(tin.slice(2, 4), 10);
-
- if (month > 50) {
- month -= 50;
- }
-
- if (month < 10) {
- month = "0".concat(month);
- } // Check date validity
-
-
- var date = "".concat(full_year, "/").concat(month, "/").concat(tin.slice(4, 6));
-
- if (!isDate(date, 'YYYY/MM/DD')) {
- return false;
- }
- }
-
- return true;
-}
-/*
- * sl-SI validation function
- * (Davčna številka, persons/entities)
- * Verify TIN validity by calculating check (last) digit (variant of MOD 11)
- */
-
-
-function slSiCheck(tin) {
- var checksum = 11 - reverseMultiplyAndSum(tin.split('').slice(0, 7).map(function (a) {
- return parseInt(a, 10);
- }), 8) % 11;
-
- if (checksum === 10) {
- return parseInt(tin[7], 10) === 0;
- }
-
- return checksum === parseInt(tin[7], 10);
-}
-/*
- * sv-SE validation function
- * (Personnummer or samordningsnummer, persons only)
- * Checks validity of birth date and calls luhnCheck() to validate check (last) digit
- */
-
-
-function svSeCheck(tin) {
- // Make copy of TIN and normalize to two-digit year form
- var tin_copy = tin.slice(0);
-
- if (tin.length > 11) {
- tin_copy = tin_copy.slice(2);
- } // Extract date of birth
-
-
- var full_year = '';
- var month = tin_copy.slice(2, 4);
- var day = parseInt(tin_copy.slice(4, 6), 10);
-
- if (tin.length > 11) {
- full_year = tin.slice(0, 4);
- } else {
- full_year = tin.slice(0, 2);
-
- if (tin.length === 11 && day < 60) {
- // Extract full year from centenarian symbol
- // Should work just fine until year 10000 or so
- var current_year = new Date().getFullYear().toString();
- var current_century = parseInt(current_year.slice(0, 2), 10);
- current_year = parseInt(current_year, 10);
-
- if (tin[6] === '-') {
- if (parseInt("".concat(current_century).concat(full_year), 10) > current_year) {
- full_year = "".concat(current_century - 1).concat(full_year);
- } else {
- full_year = "".concat(current_century).concat(full_year);
- }
- } else {
- full_year = "".concat(current_century - 1).concat(full_year);
-
- if (current_year - parseInt(full_year, 10) < 100) {
- return false;
- }
- }
- }
- } // Normalize day and check date validity
-
-
- if (day > 60) {
- day -= 60;
- }
-
- if (day < 10) {
- day = "0".concat(day);
- }
-
- var date = "".concat(full_year, "/").concat(month, "/").concat(day);
-
- if (date.length === 8) {
- if (!isDate(date, 'YY/MM/DD')) {
- return false;
- }
- } else if (!isDate(date, 'YYYY/MM/DD')) {
- return false;
- }
-
- return luhnCheck(tin.replace(/\W/, ''));
-} // Locale lookup objects
-
-/*
- * Tax id regex formats for various locales
- *
- * Where not explicitly specified in DG-TAXUD document both
- * uppercase and lowercase letters are acceptable.
- */
-
-
-var taxIdFormat = {
- 'bg-BG': /^\d{10}$/,
- 'cs-CZ': /^\d{6}\/{0,1}\d{3,4}$/,
- 'de-AT': /^\d{9}$/,
- 'de-DE': /^[1-9]\d{10}$/,
- 'dk-DK': /^\d{6}-{0,1}\d{4}$/,
- 'el-CY': /^[09]\d{7}[A-Z]$/,
- 'el-GR': /^([0-4]|[7-9])\d{8}$/,
- 'en-GB': /^\d{10}$|^(?!GB|NK|TN|ZZ)(?![DFIQUV])[A-Z](?![DFIQUVO])[A-Z]\d{6}[ABCD ]$/i,
- 'en-IE': /^\d{7}[A-W][A-IW]{0,1}$/i,
- 'en-US': /^\d{2}[- ]{0,1}\d{7}$/,
- 'es-ES': /^(\d{0,8}|[XYZKLM]\d{7})[A-HJ-NP-TV-Z]$/i,
- 'et-EE': /^[1-6]\d{6}(00[1-9]|0[1-9][0-9]|[1-6][0-9]{2}|70[0-9]|710)\d$/,
- 'fi-FI': /^\d{6}[-+A]\d{3}[0-9A-FHJ-NPR-Y]$/i,
- 'fr-BE': /^\d{11}$/,
- 'fr-FR': /^[0-3]\d{12}$|^[0-3]\d\s\d{2}(\s\d{3}){3}$/,
- // Conforms both to official spec and provided example
- 'fr-LU': /^\d{13}$/,
- 'hr-HR': /^\d{11}$/,
- 'hu-HU': /^8\d{9}$/,
- 'it-IT': /^[A-Z]{6}[L-NP-V0-9]{2}[A-EHLMPRST][L-NP-V0-9]{2}[A-ILMZ][L-NP-V0-9]{3}[A-Z]$/i,
- 'lv-LV': /^\d{6}-{0,1}\d{5}$/,
- // Conforms both to DG TAXUD spec and original research
- 'mt-MT': /^\d{3,7}[APMGLHBZ]$|^([1-8])\1\d{7}$/i,
- 'nl-NL': /^\d{9}$/,
- 'pl-PL': /^\d{10,11}$/,
- 'pt-PT': /^\d{9}$/,
- 'ro-RO': /^\d{13}$/,
- 'sk-SK': /^\d{6}\/{0,1}\d{3,4}$/,
- 'sl-SI': /^[1-9]\d{7}$/,
- 'sv-SE': /^(\d{6}[-+]{0,1}\d{4}|(18|19|20)\d{6}[-+]{0,1}\d{4})$/
-}; // taxIdFormat locale aliases
-
-taxIdFormat['lb-LU'] = taxIdFormat['fr-LU'];
-taxIdFormat['lt-LT'] = taxIdFormat['et-EE'];
-taxIdFormat['nl-BE'] = taxIdFormat['fr-BE']; // Algorithmic tax id check functions for various locales
-
-var taxIdCheck = {
- 'bg-BG': bgBgCheck,
- 'cs-CZ': csCzCheck,
- 'de-AT': deAtCheck,
- 'de-DE': deDeCheck,
- 'dk-DK': dkDkCheck,
- 'el-CY': elCyCheck,
- 'el-GR': elGrCheck,
- 'en-IE': enIeCheck,
- 'en-US': enUsCheck,
- 'es-ES': esEsCheck,
- 'et-EE': etEeCheck,
- 'fi-FI': fiFiCheck,
- 'fr-BE': frBeCheck,
- 'fr-FR': frFrCheck,
- 'fr-LU': frLuCheck,
- 'hr-HR': hrHrCheck,
- 'hu-HU': huHuCheck,
- 'it-IT': itItCheck,
- 'lv-LV': lvLvCheck,
- 'mt-MT': mtMtCheck,
- 'nl-NL': nlNlCheck,
- 'pl-PL': plPlCheck,
- 'pt-PT': ptPtCheck,
- 'ro-RO': roRoCheck,
- 'sk-SK': skSkCheck,
- 'sl-SI': slSiCheck,
- 'sv-SE': svSeCheck
-}; // taxIdCheck locale aliases
-
-taxIdCheck['lb-LU'] = taxIdCheck['fr-LU'];
-taxIdCheck['lt-LT'] = taxIdCheck['et-EE'];
-taxIdCheck['nl-BE'] = taxIdCheck['fr-BE']; // Regexes for locales where characters should be omitted before checking format
-
-var allsymbols = /[-\\\/!@#$%\^&\*\(\)\+\=\[\]]+/g;
-var sanitizeRegexes = {
- 'de-AT': allsymbols,
- 'de-DE': /[\/\\]/g,
- 'fr-BE': allsymbols
-}; // sanitizeRegexes locale aliases
-
-sanitizeRegexes['nl-BE'] = sanitizeRegexes['fr-BE'];
-/*
- * Validator function
- * Return true if the passed string is a valid tax identification number
- * for the specified locale.
- * Throw an error exception if the locale is not supported.
- */
-
-function isTaxID(str) {
- var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US';
- assertString(str); // Copy TIN to avoid replacement if sanitized
-
- var strcopy = str.slice(0);
-
- if (locale in taxIdFormat) {
- if (locale in sanitizeRegexes) {
- strcopy = strcopy.replace(sanitizeRegexes[locale], '');
- }
-
- if (!taxIdFormat[locale].test(strcopy)) {
- return false;
- }
-
- if (locale in taxIdCheck) {
- return taxIdCheck[locale](strcopy);
- } // Fallthrough; not all locales have algorithmic checks
-
-
- return true;
- }
-
- throw new Error("Invalid locale '".concat(locale, "'"));
-}
-
-/* eslint-disable max-len */
-
-var phones = {
- 'am-AM': /^(\+?374|0)((10|[9|7][0-9])\d{6}$|[2-4]\d{7}$)/,
- 'ar-AE': /^((\+?971)|0)?5[024568]\d{7}$/,
- 'ar-BH': /^(\+?973)?(3|6)\d{7}$/,
- 'ar-DZ': /^(\+?213|0)(5|6|7)\d{8}$/,
- 'ar-LB': /^(\+?961)?((3|81)\d{6}|7\d{7})$/,
- 'ar-EG': /^((\+?20)|0)?1[0125]\d{8}$/,
- 'ar-IQ': /^(\+?964|0)?7[0-9]\d{8}$/,
- 'ar-JO': /^(\+?962|0)?7[789]\d{7}$/,
- 'ar-KW': /^(\+?965)[569]\d{7}$/,
- 'ar-LY': /^((\+?218)|0)?(9[1-6]\d{7}|[1-8]\d{7,9})$/,
- 'ar-MA': /^(?:(?:\+|00)212|0)[5-7]\d{8}$/,
- 'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/,
- 'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/,
- 'ar-TN': /^(\+?216)?[2459]\d{7}$/,
- 'az-AZ': /^(\+994|0)(5[015]|7[07]|99)\d{7}$/,
- 'bs-BA': /^((((\+|00)3876)|06))((([0-3]|[5-6])\d{6})|(4\d{7}))$/,
- 'be-BY': /^(\+?375)?(24|25|29|33|44)\d{7}$/,
- 'bg-BG': /^(\+?359|0)?8[789]\d{7}$/,
- 'bn-BD': /^(\+?880|0)1[13456789][0-9]{8}$/,
- 'ca-AD': /^(\+376)?[346]\d{5}$/,
- 'cs-CZ': /^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
- 'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/,
- 'de-DE': /^(\+49)?0?[1|3]([0|5][0-45-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7}$/,
- 'de-AT': /^(\+43|0)\d{1,4}\d{3,12}$/,
- 'de-CH': /^(\+41|0)(7[5-9])\d{1,7}$/,
- 'de-LU': /^(\+352)?((6\d1)\d{6})$/,
- 'el-GR': /^(\+?30|0)?(69\d{8})$/,
- 'en-AU': /^(\+?61|0)4\d{8}$/,
- 'en-GB': /^(\+?44|0)7\d{9}$/,
- 'en-GG': /^(\+?44|0)1481\d{6}$/,
- 'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28)\d{7}$/,
- 'en-HK': /^(\+?852[-\s]?)?[456789]\d{3}[-\s]?\d{4}$/,
- 'en-MO': /^(\+?853[-\s]?)?[6]\d{3}[-\s]?\d{4}$/,
- 'en-IE': /^(\+?353|0)8[356789]\d{7}$/,
- 'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
- 'en-KE': /^(\+?254|0)(7|1)\d{8}$/,
- 'en-MT': /^(\+?356|0)?(99|79|77|21|27|22|25)[0-9]{6}$/,
- 'en-MU': /^(\+?230|0)?\d{8}$/,
- 'en-NG': /^(\+?234|0)?[789]\d{9}$/,
- 'en-NZ': /^(\+?64|0)[28]\d{7,9}$/,
- 'en-PK': /^((\+92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$/,
- 'en-PH': /^(09|\+639)\d{9}$/,
- 'en-RW': /^(\+?250|0)?[7]\d{8}$/,
- 'en-SG': /^(\+65)?[689]\d{7}$/,
- 'en-SL': /^(?:0|94|\+94)?(7(0|1|2|5|6|7|8)( |-)?\d)\d{6}$/,
- 'en-TZ': /^(\+?255|0)?[67]\d{8}$/,
- 'en-UG': /^(\+?256|0)?[7]\d{8}$/,
- 'en-US': /^((\+1|1)?( |-)?)?(\([2-9][0-9]{2}\)|[2-9][0-9]{2})( |-)?([2-9][0-9]{2}( |-)?[0-9]{4})$/,
- 'en-ZA': /^(\+?27|0)\d{9}$/,
- 'en-ZM': /^(\+?26)?09[567]\d{7}$/,
- 'en-ZW': /^(\+263)[0-9]{9}$/,
- 'es-AR': /^\+?549(11|[2368]\d)\d{8}$/,
- 'es-BO': /^(\+?591)?(6|7)\d{7}$/,
- 'es-CO': /^(\+?57)?([1-8]{1}|3[0-9]{2})?[2-9]{1}\d{6}$/,
- 'es-CL': /^(\+?56|0)[2-9]\d{1}\d{7}$/,
- 'es-CR': /^(\+506)?[2-8]\d{7}$/,
- 'es-DO': /^(\+?1)?8[024]9\d{7}$/,
- 'es-HN': /^(\+?504)?[9|8]\d{7}$/,
- 'es-EC': /^(\+?593|0)([2-7]|9[2-9])\d{7}$/,
- 'es-ES': /^(\+?34)?[6|7]\d{8}$/,
- 'es-PE': /^(\+?51)?9\d{8}$/,
- 'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/,
- 'es-PA': /^(\+?507)\d{7,8}$/,
- 'es-PY': /^(\+?595|0)9[9876]\d{7}$/,
- 'es-UY': /^(\+598|0)9[1-9][\d]{6}$/,
- 'et-EE': /^(\+?372)?\s?(5|8[1-4])\s?([0-9]\s?){6,7}$/,
- 'fa-IR': /^(\+?98[\-\s]?|0)9[0-39]\d[\-\s]?\d{3}[\-\s]?\d{4}$/,
- 'fi-FI': /^(\+?358|0)\s?(4(0|1|2|4|5|6)?|50)\s?(\d\s?){4,8}\d$/,
- 'fj-FJ': /^(\+?679)?\s?\d{3}\s?\d{4}$/,
- 'fo-FO': /^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
- 'fr-FR': /^(\+?33|0)[67]\d{8}$/,
- 'fr-GF': /^(\+?594|0|00594)[67]\d{8}$/,
- 'fr-GP': /^(\+?590|0|00590)[67]\d{8}$/,
- 'fr-MQ': /^(\+?596|0|00596)[67]\d{8}$/,
- 'fr-RE': /^(\+?262|0|00262)[67]\d{8}$/,
- 'he-IL': /^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}$/,
- 'hu-HU': /^(\+?36)(20|30|70)\d{7}$/,
- 'id-ID': /^(\+?62|0)8(1[123456789]|2[1238]|3[1238]|5[12356789]|7[78]|9[56789]|8[123456789])([\s?|\d]{5,11})$/,
- 'it-IT': /^(\+?39)?\s?3\d{2} ?\d{6,7}$/,
- 'it-SM': /^((\+378)|(0549)|(\+390549)|(\+3780549))?6\d{5,9}$/,
- 'ja-JP': /^(\+81[ \-]?(\(0\))?|0)[6789]0[ \-]?\d{4}[ \-]?\d{4}$/,
- 'ka-GE': /^(\+?995)?(5|79)\d{7}$/,
- 'kk-KZ': /^(\+?7|8)?7\d{9}$/,
- 'kl-GL': /^(\+?299)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
- 'ko-KR': /^((\+?82)[ \-]?)?0?1([0|1|6|7|8|9]{1})[ \-]?\d{3,4}[ \-]?\d{4}$/,
- 'lt-LT': /^(\+370|8)\d{8}$/,
- 'ms-MY': /^(\+?6?01){1}(([0145]{1}(\-|\s)?\d{7,8})|([236789]{1}(\s|\-)?\d{7}))$/,
- 'nb-NO': /^(\+?47)?[49]\d{7}$/,
- 'ne-NP': /^(\+?977)?9[78]\d{8}$/,
- 'nl-BE': /^(\+?32|0)4?\d{8}$/,
- 'nl-NL': /^(((\+|00)?31\(0\))|((\+|00)?31)|0)6{1}\d{8}$/,
- 'nn-NO': /^(\+?47)?[49]\d{7}$/,
- 'pl-PL': /^(\+?48)? ?[5-8]\d ?\d{3} ?\d{2} ?\d{2}$/,
- 'pt-BR': /^((\+?55\ ?[1-9]{2}\ ?)|(\+?55\ ?\([1-9]{2}\)\ ?)|(0[1-9]{2}\ ?)|(\([1-9]{2}\)\ ?)|([1-9]{2}\ ?))((\d{4}\-?\d{4})|(9[2-9]{1}\d{3}\-?\d{4}))$/,
- 'pt-PT': /^(\+?351)?9[1236]\d{7}$/,
- 'ro-RO': /^(\+?4?0)\s?7\d{2}(\/|\s|\.|\-)?\d{3}(\s|\.|\-)?\d{3}$/,
- 'ru-RU': /^(\+?7|8)?9\d{9}$/,
- 'sl-SI': /^(\+386\s?|0)(\d{1}\s?\d{3}\s?\d{2}\s?\d{2}|\d{2}\s?\d{3}\s?\d{3})$/,
- 'sk-SK': /^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
- 'sq-AL': /^(\+355|0)6[789]\d{6}$/,
- 'sr-RS': /^(\+3816|06)[- \d]{5,9}$/,
- 'sv-SE': /^(\+?46|0)[\s\-]?7[\s\-]?[02369]([\s\-]?\d){7}$/,
- 'th-TH': /^(\+66|66|0)\d{9}$/,
- 'tr-TR': /^(\+?90|0)?5\d{9}$/,
- 'uk-UA': /^(\+?38|8)?0\d{9}$/,
- 'uz-UZ': /^(\+?998)?(6[125-79]|7[1-69]|88|9\d)\d{7}$/,
- 'vi-VN': /^(\+?84|0)((3([2-9]))|(5([2689]))|(7([0|6-9]))|(8([1-6|89]))|(9([0-9])))([0-9]{7})$/,
- 'zh-CN': /^((\+|00)86)?1([3568][0-9]|4[579]|6[67]|7[01235678]|9[012356789])[0-9]{8}$/,
- 'zh-TW': /^(\+?886\-?|0)?9\d{8}$/
-};
-/* eslint-enable max-len */
-// aliases
-
-phones['en-CA'] = phones['en-US'];
-phones['fr-CA'] = phones['en-CA'];
-phones['fr-BE'] = phones['nl-BE'];
-phones['zh-HK'] = phones['en-HK'];
-phones['zh-MO'] = phones['en-MO'];
-phones['ga-IE'] = phones['en-IE'];
-function isMobilePhone(str, locale, options) {
- assertString(str);
-
- if (options && options.strictMode && !str.startsWith('+')) {
- return false;
- }
-
- if (Array.isArray(locale)) {
- return locale.some(function (key) {
- // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
- // istanbul ignore else
- if (phones.hasOwnProperty(key)) {
- var phone = phones[key];
-
- if (phone.test(str)) {
- return true;
- }
- }
-
- return false;
- });
- } else if (locale in phones) {
- return phones[locale].test(str); // alias falsey locale as 'any'
- } else if (!locale || locale === 'any') {
- for (var key in phones) {
- // istanbul ignore else
- if (phones.hasOwnProperty(key)) {
- var phone = phones[key];
-
- if (phone.test(str)) {
- return true;
- }
- }
- }
-
- return false;
- }
-
- throw new Error("Invalid locale '".concat(locale, "'"));
-}
-var locales$3 = Object.keys(phones);
-
-var eth = /^(0x)[0-9a-f]{40}$/i;
-function isEthereumAddress(str) {
- assertString(str);
- return eth.test(str);
-}
-
-function currencyRegex(options) {
- var decimal_digits = "\\d{".concat(options.digits_after_decimal[0], "}");
- options.digits_after_decimal.forEach(function (digit, index) {
- if (index !== 0) decimal_digits = "".concat(decimal_digits, "|\\d{").concat(digit, "}");
- });
- var symbol = "(".concat(options.symbol.replace(/\W/, function (m) {
- return "\\".concat(m);
- }), ")").concat(options.require_symbol ? '' : '?'),
- negative = '-?',
- whole_dollar_amount_without_sep = '[1-9]\\d*',
- whole_dollar_amount_with_sep = "[1-9]\\d{0,2}(\\".concat(options.thousands_separator, "\\d{3})*"),
- valid_whole_dollar_amounts = ['0', whole_dollar_amount_without_sep, whole_dollar_amount_with_sep],
- whole_dollar_amount = "(".concat(valid_whole_dollar_amounts.join('|'), ")?"),
- decimal_amount = "(\\".concat(options.decimal_separator, "(").concat(decimal_digits, "))").concat(options.require_decimal ? '' : '?');
- var pattern = whole_dollar_amount + (options.allow_decimal || options.require_decimal ? decimal_amount : ''); // default is negative sign before symbol, but there are two other options (besides parens)
-
- if (options.allow_negatives && !options.parens_for_negatives) {
- if (options.negative_sign_after_digits) {
- pattern += negative;
- } else if (options.negative_sign_before_digits) {
- pattern = negative + pattern;
- }
- } // South African Rand, for example, uses R 123 (space) and R-123 (no space)
-
-
- if (options.allow_negative_sign_placeholder) {
- pattern = "( (?!\\-))?".concat(pattern);
- } else if (options.allow_space_after_symbol) {
- pattern = " ?".concat(pattern);
- } else if (options.allow_space_after_digits) {
- pattern += '( (?!$))?';
- }
-
- if (options.symbol_after_digits) {
- pattern += symbol;
- } else {
- pattern = symbol + pattern;
- }
-
- if (options.allow_negatives) {
- if (options.parens_for_negatives) {
- pattern = "(\\(".concat(pattern, "\\)|").concat(pattern, ")");
- } else if (!(options.negative_sign_before_digits || options.negative_sign_after_digits)) {
- pattern = negative + pattern;
- }
- } // ensure there's a dollar and/or decimal amount, and that
- // it doesn't start with a space or a negative sign followed by a space
-
-
- return new RegExp("^(?!-? )(?=.*\\d)".concat(pattern, "$"));
-}
-
-var default_currency_options = {
- symbol: '$',
- require_symbol: false,
- allow_space_after_symbol: false,
- symbol_after_digits: false,
- allow_negatives: true,
- parens_for_negatives: false,
- negative_sign_before_digits: false,
- negative_sign_after_digits: false,
- allow_negative_sign_placeholder: false,
- thousands_separator: ',',
- decimal_separator: '.',
- allow_decimal: true,
- require_decimal: false,
- digits_after_decimal: [2],
- allow_space_after_digits: false
-};
-function isCurrency(str, options) {
- assertString(str);
- options = merge(options, default_currency_options);
- return currencyRegex(options).test(str);
-}
-
-var btc = /^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,39}$/;
-function isBtcAddress(str) {
- assertString(str);
- return btc.test(str);
-}
-
-/* eslint-disable max-len */
-// from http://goo.gl/0ejHHW
-
-var iso8601 = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/; // same as above, except with a strict 'T' separator between date and time
-
-var iso8601StrictSeparator = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;
-/* eslint-enable max-len */
-
-var isValidDate = function isValidDate(str) {
- // str must have passed the ISO8601 check
- // this check is meant to catch invalid dates
- // like 2009-02-31
- // first check for ordinal dates
- var ordinalMatch = str.match(/^(\d{4})-?(\d{3})([ T]{1}\.*|$)/);
-
- if (ordinalMatch) {
- var oYear = Number(ordinalMatch[1]);
- var oDay = Number(ordinalMatch[2]); // if is leap year
-
- if (oYear % 4 === 0 && oYear % 100 !== 0 || oYear % 400 === 0) return oDay <= 366;
- return oDay <= 365;
- }
-
- var match = str.match(/(\d{4})-?(\d{0,2})-?(\d*)/).map(Number);
- var year = match[1];
- var month = match[2];
- var day = match[3];
- var monthString = month ? "0".concat(month).slice(-2) : month;
- var dayString = day ? "0".concat(day).slice(-2) : day; // create a date object and compare
-
- var d = new Date("".concat(year, "-").concat(monthString || '01', "-").concat(dayString || '01'));
-
- if (month && day) {
- return d.getUTCFullYear() === year && d.getUTCMonth() + 1 === month && d.getUTCDate() === day;
- }
-
- return true;
-};
-
-function isISO8601(str) {
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- assertString(str);
- var check = options.strictSeparator ? iso8601StrictSeparator.test(str) : iso8601.test(str);
- if (check && options.strict) return isValidDate(str);
- return check;
-}
-
-/* Based on https://tools.ietf.org/html/rfc3339#section-5.6 */
-
-var dateFullYear = /[0-9]{4}/;
-var dateMonth = /(0[1-9]|1[0-2])/;
-var dateMDay = /([12]\d|0[1-9]|3[01])/;
-var timeHour = /([01][0-9]|2[0-3])/;
-var timeMinute = /[0-5][0-9]/;
-var timeSecond = /([0-5][0-9]|60)/;
-var timeSecFrac = /(\.[0-9]+)?/;
-var timeNumOffset = new RegExp("[-+]".concat(timeHour.source, ":").concat(timeMinute.source));
-var timeOffset = new RegExp("([zZ]|".concat(timeNumOffset.source, ")"));
-var partialTime = new RegExp("".concat(timeHour.source, ":").concat(timeMinute.source, ":").concat(timeSecond.source).concat(timeSecFrac.source));
-var fullDate = new RegExp("".concat(dateFullYear.source, "-").concat(dateMonth.source, "-").concat(dateMDay.source));
-var fullTime = new RegExp("".concat(partialTime.source).concat(timeOffset.source));
-var rfc3339 = new RegExp("".concat(fullDate.source, "[ tT]").concat(fullTime.source));
-function isRFC3339(str) {
- assertString(str);
- return rfc3339.test(str);
-}
-
-var validISO31661Alpha2CountriesCodes = ['AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AO', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GG', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IO', 'IQ', 'IR', 'IS', 'IT', 'JE', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM', 'PN', 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SD', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'SS', 'ST', 'SV', 'SX', 'SY', 'SZ', 'TC', 'TD', 'TF', 'TG', 'TH', 'TJ', 'TK', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'UM', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VG', 'VI', 'VN', 'VU', 'WF', 'WS', 'YE', 'YT', 'ZA', 'ZM', 'ZW'];
-function isISO31661Alpha2(str) {
- assertString(str);
- return includes(validISO31661Alpha2CountriesCodes, str.toUpperCase());
-}
-
-var validISO31661Alpha3CountriesCodes = ['AFG', 'ALA', 'ALB', 'DZA', 'ASM', 'AND', 'AGO', 'AIA', 'ATA', 'ATG', 'ARG', 'ARM', 'ABW', 'AUS', 'AUT', 'AZE', 'BHS', 'BHR', 'BGD', 'BRB', 'BLR', 'BEL', 'BLZ', 'BEN', 'BMU', 'BTN', 'BOL', 'BES', 'BIH', 'BWA', 'BVT', 'BRA', 'IOT', 'BRN', 'BGR', 'BFA', 'BDI', 'KHM', 'CMR', 'CAN', 'CPV', 'CYM', 'CAF', 'TCD', 'CHL', 'CHN', 'CXR', 'CCK', 'COL', 'COM', 'COG', 'COD', 'COK', 'CRI', 'CIV', 'HRV', 'CUB', 'CUW', 'CYP', 'CZE', 'DNK', 'DJI', 'DMA', 'DOM', 'ECU', 'EGY', 'SLV', 'GNQ', 'ERI', 'EST', 'ETH', 'FLK', 'FRO', 'FJI', 'FIN', 'FRA', 'GUF', 'PYF', 'ATF', 'GAB', 'GMB', 'GEO', 'DEU', 'GHA', 'GIB', 'GRC', 'GRL', 'GRD', 'GLP', 'GUM', 'GTM', 'GGY', 'GIN', 'GNB', 'GUY', 'HTI', 'HMD', 'VAT', 'HND', 'HKG', 'HUN', 'ISL', 'IND', 'IDN', 'IRN', 'IRQ', 'IRL', 'IMN', 'ISR', 'ITA', 'JAM', 'JPN', 'JEY', 'JOR', 'KAZ', 'KEN', 'KIR', 'PRK', 'KOR', 'KWT', 'KGZ', 'LAO', 'LVA', 'LBN', 'LSO', 'LBR', 'LBY', 'LIE', 'LTU', 'LUX', 'MAC', 'MKD', 'MDG', 'MWI', 'MYS', 'MDV', 'MLI', 'MLT', 'MHL', 'MTQ', 'MRT', 'MUS', 'MYT', 'MEX', 'FSM', 'MDA', 'MCO', 'MNG', 'MNE', 'MSR', 'MAR', 'MOZ', 'MMR', 'NAM', 'NRU', 'NPL', 'NLD', 'NCL', 'NZL', 'NIC', 'NER', 'NGA', 'NIU', 'NFK', 'MNP', 'NOR', 'OMN', 'PAK', 'PLW', 'PSE', 'PAN', 'PNG', 'PRY', 'PER', 'PHL', 'PCN', 'POL', 'PRT', 'PRI', 'QAT', 'REU', 'ROU', 'RUS', 'RWA', 'BLM', 'SHN', 'KNA', 'LCA', 'MAF', 'SPM', 'VCT', 'WSM', 'SMR', 'STP', 'SAU', 'SEN', 'SRB', 'SYC', 'SLE', 'SGP', 'SXM', 'SVK', 'SVN', 'SLB', 'SOM', 'ZAF', 'SGS', 'SSD', 'ESP', 'LKA', 'SDN', 'SUR', 'SJM', 'SWZ', 'SWE', 'CHE', 'SYR', 'TWN', 'TJK', 'TZA', 'THA', 'TLS', 'TGO', 'TKL', 'TON', 'TTO', 'TUN', 'TUR', 'TKM', 'TCA', 'TUV', 'UGA', 'UKR', 'ARE', 'GBR', 'USA', 'UMI', 'URY', 'UZB', 'VUT', 'VEN', 'VNM', 'VGB', 'VIR', 'WLF', 'ESH', 'YEM', 'ZMB', 'ZWE'];
-function isISO31661Alpha3(str) {
- assertString(str);
- return includes(validISO31661Alpha3CountriesCodes, str.toUpperCase());
-}
-
-var base32 = /^[A-Z2-7]+=*$/;
-function isBase32(str) {
- assertString(str);
- var len = str.length;
-
- if (len % 8 === 0 && base32.test(str)) {
- return true;
- }
-
- return false;
-}
-
-var base58Reg = /^[A-HJ-NP-Za-km-z1-9]*$/;
-function isBase58(str) {
- assertString(str);
-
- if (base58Reg.test(str)) {
- return true;
- }
-
- return false;
-}
-
-var validMediaType = /^[a-z]+\/[a-z0-9\-\+]+$/i;
-var validAttribute = /^[a-z\-]+=[a-z0-9\-]+$/i;
-var validData = /^[a-z0-9!\$&'\(\)\*\+,;=\-\._~:@\/\?%\s]*$/i;
-function isDataURI(str) {
- assertString(str);
- var data = str.split(',');
-
- if (data.length < 2) {
- return false;
- }
-
- var attributes = data.shift().trim().split(';');
- var schemeAndMediaType = attributes.shift();
-
- if (schemeAndMediaType.substr(0, 5) !== 'data:') {
- return false;
- }
-
- var mediaType = schemeAndMediaType.substr(5);
-
- if (mediaType !== '' && !validMediaType.test(mediaType)) {
- return false;
- }
-
- for (var i = 0; i < attributes.length; i++) {
- if (i === attributes.length - 1 && attributes[i].toLowerCase() === 'base64') {// ok
- } else if (!validAttribute.test(attributes[i])) {
- return false;
- }
- }
-
- for (var _i = 0; _i < data.length; _i++) {
- if (!validData.test(data[_i])) {
- return false;
- }
- }
-
- return true;
-}
-
-var magnetURI = /^magnet:\?xt=urn:[a-z0-9]+:[a-z0-9]{32,40}&dn=.+&tr=.+$/i;
-function isMagnetURI(url) {
- assertString(url);
- return magnetURI.test(url.trim());
-}
-
-/*
- Checks if the provided string matches to a correct Media type format (MIME type)
-
- This function only checks is the string format follows the
- etablished rules by the according RFC specifications.
- This function supports 'charset' in textual media types
- (https://tools.ietf.org/html/rfc6657).
-
- This function does not check against all the media types listed
- by the IANA (https://www.iana.org/assignments/media-types/media-types.xhtml)
- because of lightness purposes : it would require to include
- all these MIME types in this librairy, which would weigh it
- significantly. This kind of effort maybe is not worth for the use that
- this function has in this entire librairy.
-
- More informations in the RFC specifications :
- - https://tools.ietf.org/html/rfc2045
- - https://tools.ietf.org/html/rfc2046
- - https://tools.ietf.org/html/rfc7231#section-3.1.1.1
- - https://tools.ietf.org/html/rfc7231#section-3.1.1.5
-*/
-// Match simple MIME types
-// NB :
-// Subtype length must not exceed 100 characters.
-// This rule does not comply to the RFC specs (what is the max length ?).
-
-var mimeTypeSimple = /^(application|audio|font|image|message|model|multipart|text|video)\/[a-zA-Z0-9\.\-\+]{1,100}$/i; // eslint-disable-line max-len
-// Handle "charset" in "text/*"
-
-var mimeTypeText = /^text\/[a-zA-Z0-9\.\-\+]{1,100};\s?charset=("[a-zA-Z0-9\.\-\+\s]{0,70}"|[a-zA-Z0-9\.\-\+]{0,70})(\s?\([a-zA-Z0-9\.\-\+\s]{1,20}\))?$/i; // eslint-disable-line max-len
-// Handle "boundary" in "multipart/*"
-
-var mimeTypeMultipart = /^multipart\/[a-zA-Z0-9\.\-\+]{1,100}(;\s?(boundary|charset)=("[a-zA-Z0-9\.\-\+\s]{0,70}"|[a-zA-Z0-9\.\-\+]{0,70})(\s?\([a-zA-Z0-9\.\-\+\s]{1,20}\))?){0,2}$/i; // eslint-disable-line max-len
-
-function isMimeType(str) {
- assertString(str);
- return mimeTypeSimple.test(str) || mimeTypeText.test(str) || mimeTypeMultipart.test(str);
-}
-
-var lat = /^\(?[+-]?(90(\.0+)?|[1-8]?\d(\.\d+)?)$/;
-var _long = /^\s?[+-]?(180(\.0+)?|1[0-7]\d(\.\d+)?|\d{1,2}(\.\d+)?)\)?$/;
-var latDMS = /^(([1-8]?\d)\D+([1-5]?\d|60)\D+([1-5]?\d|60)(\.\d+)?|90\D+0\D+0)\D+[NSns]?$/i;
-var longDMS = /^\s*([1-7]?\d{1,2}\D+([1-5]?\d|60)\D+([1-5]?\d|60)(\.\d+)?|180\D+0\D+0)\D+[EWew]?$/i;
-var defaultLatLongOptions = {
- checkDMS: false
-};
-function isLatLong(str, options) {
- assertString(str);
- options = merge(options, defaultLatLongOptions);
- if (!str.includes(',')) return false;
- var pair = str.split(',');
- if (pair[0].startsWith('(') && !pair[1].endsWith(')') || pair[1].endsWith(')') && !pair[0].startsWith('(')) return false;
-
- if (options.checkDMS) {
- return latDMS.test(pair[0]) && longDMS.test(pair[1]);
- }
-
- return lat.test(pair[0]) && _long.test(pair[1]);
-}
-
-var threeDigit = /^\d{3}$/;
-var fourDigit = /^\d{4}$/;
-var fiveDigit = /^\d{5}$/;
-var sixDigit = /^\d{6}$/;
-var patterns = {
- AD: /^AD\d{3}$/,
- AT: fourDigit,
- AU: fourDigit,
- AZ: /^AZ\d{4}$/,
- BE: fourDigit,
- BG: fourDigit,
- BR: /^\d{5}-\d{3}$/,
- BY: /2[1-4]{1}\d{4}$/,
- CA: /^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][\s\-]?\d[ABCEGHJ-NPRSTV-Z]\d$/i,
- CH: fourDigit,
- CN: /^(0[1-7]|1[012356]|2[0-7]|3[0-6]|4[0-7]|5[1-7]|6[1-7]|7[1-5]|8[1345]|9[09])\d{4}$/,
- CZ: /^\d{3}\s?\d{2}$/,
- DE: fiveDigit,
- DK: fourDigit,
- DO: fiveDigit,
- DZ: fiveDigit,
- EE: fiveDigit,
- ES: /^(5[0-2]{1}|[0-4]{1}\d{1})\d{3}$/,
- FI: fiveDigit,
- FR: /^\d{2}\s?\d{3}$/,
- GB: /^(gir\s?0aa|[a-z]{1,2}\d[\da-z]?\s?(\d[a-z]{2})?)$/i,
- GR: /^\d{3}\s?\d{2}$/,
- HR: /^([1-5]\d{4}$)/,
- HT: /^HT\d{4}$/,
- HU: fourDigit,
- ID: fiveDigit,
- IE: /^(?!.*(?:o))[A-z]\d[\dw]\s\w{4}$/i,
- IL: /^(\d{5}|\d{7})$/,
- IN: /^((?!10|29|35|54|55|65|66|86|87|88|89)[1-9][0-9]{5})$/,
- IR: /\b(?!(\d)\1{3})[13-9]{4}[1346-9][013-9]{5}\b/,
- IS: threeDigit,
- IT: fiveDigit,
- JP: /^\d{3}\-\d{4}$/,
- KE: fiveDigit,
- LI: /^(948[5-9]|949[0-7])$/,
- LT: /^LT\-\d{5}$/,
- LU: fourDigit,
- LV: /^LV\-\d{4}$/,
- MX: fiveDigit,
- MT: /^[A-Za-z]{3}\s{0,1}\d{4}$/,
- MY: fiveDigit,
- NL: /^\d{4}\s?[a-z]{2}$/i,
- NO: fourDigit,
- NP: /^(10|21|22|32|33|34|44|45|56|57)\d{3}$|^(977)$/i,
- NZ: fourDigit,
- PL: /^\d{2}\-\d{3}$/,
- PR: /^00[679]\d{2}([ -]\d{4})?$/,
- PT: /^\d{4}\-\d{3}?$/,
- RO: sixDigit,
- RU: sixDigit,
- SA: fiveDigit,
- SE: /^[1-9]\d{2}\s?\d{2}$/,
- SG: sixDigit,
- SI: fourDigit,
- SK: /^\d{3}\s?\d{2}$/,
- TH: fiveDigit,
- TN: fourDigit,
- TW: /^\d{3}(\d{2})?$/,
- UA: fiveDigit,
- US: /^\d{5}(-\d{4})?$/,
- ZA: fourDigit,
- ZM: fiveDigit
-};
-var locales$4 = Object.keys(patterns);
-function isPostalCode(str, locale) {
- assertString(str);
-
- if (locale in patterns) {
- return patterns[locale].test(str);
- } else if (locale === 'any') {
- for (var key in patterns) {
- // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes
- // istanbul ignore else
- if (patterns.hasOwnProperty(key)) {
- var pattern = patterns[key];
-
- if (pattern.test(str)) {
- return true;
- }
- }
- }
-
- return false;
- }
-
- throw new Error("Invalid locale '".concat(locale, "'"));
-}
-
-function ltrim(str, chars) {
- assertString(str); // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
-
- var pattern = chars ? new RegExp("^[".concat(chars.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), "]+"), 'g') : /^\s+/g;
- return str.replace(pattern, '');
-}
-
-function rtrim(str, chars) {
- assertString(str); // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
-
- var pattern = chars ? new RegExp("[".concat(chars.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), "]+$"), 'g') : /\s+$/g;
- return str.replace(pattern, '');
-}
-
-function trim(str, chars) {
- return rtrim(ltrim(str, chars), chars);
-}
-
-function escape(str) {
- assertString(str);
- return str.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, ''').replace(//g, '>').replace(/\//g, '/').replace(/\\/g, '\').replace(/`/g, '`');
-}
-
-function unescape(str) {
- assertString(str);
- return str.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, "'").replace(/</g, '<').replace(/>/g, '>').replace(///g, '/').replace(/\/g, '\\').replace(/`/g, '`');
-}
-
-function blacklist$1(str, chars) {
- assertString(str);
- return str.replace(new RegExp("[".concat(chars, "]+"), 'g'), '');
-}
-
-function stripLow(str, keep_new_lines) {
- assertString(str);
- var chars = keep_new_lines ? '\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F' : '\\x00-\\x1F\\x7F';
- return blacklist$1(str, chars);
-}
-
-function whitelist(str, chars) {
- assertString(str);
- return str.replace(new RegExp("[^".concat(chars, "]+"), 'g'), '');
-}
-
-function isWhitelisted(str, chars) {
- assertString(str);
-
- for (var i = str.length - 1; i >= 0; i--) {
- if (chars.indexOf(str[i]) === -1) {
- return false;
- }
- }
-
- return true;
-}
-
-var default_normalize_email_options = {
- // The following options apply to all email addresses
- // Lowercases the local part of the email address.
- // Please note this may violate RFC 5321 as per http://stackoverflow.com/a/9808332/192024).
- // The domain is always lowercased, as per RFC 1035
- all_lowercase: true,
- // The following conversions are specific to GMail
- // Lowercases the local part of the GMail address (known to be case-insensitive)
- gmail_lowercase: true,
- // Removes dots from the local part of the email address, as that's ignored by GMail
- gmail_remove_dots: true,
- // Removes the subaddress (e.g. "+foo") from the email address
- gmail_remove_subaddress: true,
- // Conversts the googlemail.com domain to gmail.com
- gmail_convert_googlemaildotcom: true,
- // The following conversions are specific to Outlook.com / Windows Live / Hotmail
- // Lowercases the local part of the Outlook.com address (known to be case-insensitive)
- outlookdotcom_lowercase: true,
- // Removes the subaddress (e.g. "+foo") from the email address
- outlookdotcom_remove_subaddress: true,
- // The following conversions are specific to Yahoo
- // Lowercases the local part of the Yahoo address (known to be case-insensitive)
- yahoo_lowercase: true,
- // Removes the subaddress (e.g. "-foo") from the email address
- yahoo_remove_subaddress: true,
- // The following conversions are specific to Yandex
- // Lowercases the local part of the Yandex address (known to be case-insensitive)
- yandex_lowercase: true,
- // The following conversions are specific to iCloud
- // Lowercases the local part of the iCloud address (known to be case-insensitive)
- icloud_lowercase: true,
- // Removes the subaddress (e.g. "+foo") from the email address
- icloud_remove_subaddress: true
-}; // List of domains used by iCloud
-
-var icloud_domains = ['icloud.com', 'me.com']; // List of domains used by Outlook.com and its predecessors
-// This list is likely incomplete.
-// Partial reference:
-// https://blogs.office.com/2013/04/17/outlook-com-gets-two-step-verification-sign-in-by-alias-and-new-international-domains/
-
-var outlookdotcom_domains = ['hotmail.at', 'hotmail.be', 'hotmail.ca', 'hotmail.cl', 'hotmail.co.il', 'hotmail.co.nz', 'hotmail.co.th', 'hotmail.co.uk', 'hotmail.com', 'hotmail.com.ar', 'hotmail.com.au', 'hotmail.com.br', 'hotmail.com.gr', 'hotmail.com.mx', 'hotmail.com.pe', 'hotmail.com.tr', 'hotmail.com.vn', 'hotmail.cz', 'hotmail.de', 'hotmail.dk', 'hotmail.es', 'hotmail.fr', 'hotmail.hu', 'hotmail.id', 'hotmail.ie', 'hotmail.in', 'hotmail.it', 'hotmail.jp', 'hotmail.kr', 'hotmail.lv', 'hotmail.my', 'hotmail.ph', 'hotmail.pt', 'hotmail.sa', 'hotmail.sg', 'hotmail.sk', 'live.be', 'live.co.uk', 'live.com', 'live.com.ar', 'live.com.mx', 'live.de', 'live.es', 'live.eu', 'live.fr', 'live.it', 'live.nl', 'msn.com', 'outlook.at', 'outlook.be', 'outlook.cl', 'outlook.co.il', 'outlook.co.nz', 'outlook.co.th', 'outlook.com', 'outlook.com.ar', 'outlook.com.au', 'outlook.com.br', 'outlook.com.gr', 'outlook.com.pe', 'outlook.com.tr', 'outlook.com.vn', 'outlook.cz', 'outlook.de', 'outlook.dk', 'outlook.es', 'outlook.fr', 'outlook.hu', 'outlook.id', 'outlook.ie', 'outlook.in', 'outlook.it', 'outlook.jp', 'outlook.kr', 'outlook.lv', 'outlook.my', 'outlook.ph', 'outlook.pt', 'outlook.sa', 'outlook.sg', 'outlook.sk', 'passport.com']; // List of domains used by Yahoo Mail
-// This list is likely incomplete
-
-var yahoo_domains = ['rocketmail.com', 'yahoo.ca', 'yahoo.co.uk', 'yahoo.com', 'yahoo.de', 'yahoo.fr', 'yahoo.in', 'yahoo.it', 'ymail.com']; // List of domains used by yandex.ru
-
-var yandex_domains = ['yandex.ru', 'yandex.ua', 'yandex.kz', 'yandex.com', 'yandex.by', 'ya.ru']; // replace single dots, but not multiple consecutive dots
-
-function dotsReplacer(match) {
- if (match.length > 1) {
- return match;
- }
-
- return '';
-}
-
-function normalizeEmail(email, options) {
- options = merge(options, default_normalize_email_options);
- var raw_parts = email.split('@');
- var domain = raw_parts.pop();
- var user = raw_parts.join('@');
- var parts = [user, domain]; // The domain is always lowercased, as it's case-insensitive per RFC 1035
-
- parts[1] = parts[1].toLowerCase();
-
- if (parts[1] === 'gmail.com' || parts[1] === 'googlemail.com') {
- // Address is GMail
- if (options.gmail_remove_subaddress) {
- parts[0] = parts[0].split('+')[0];
- }
-
- if (options.gmail_remove_dots) {
- // this does not replace consecutive dots like example..email@gmail.com
- parts[0] = parts[0].replace(/\.+/g, dotsReplacer);
- }
-
- if (!parts[0].length) {
- return false;
- }
-
- if (options.all_lowercase || options.gmail_lowercase) {
- parts[0] = parts[0].toLowerCase();
- }
-
- parts[1] = options.gmail_convert_googlemaildotcom ? 'gmail.com' : parts[1];
- } else if (icloud_domains.indexOf(parts[1]) >= 0) {
- // Address is iCloud
- if (options.icloud_remove_subaddress) {
- parts[0] = parts[0].split('+')[0];
- }
-
- if (!parts[0].length) {
- return false;
- }
-
- if (options.all_lowercase || options.icloud_lowercase) {
- parts[0] = parts[0].toLowerCase();
- }
- } else if (outlookdotcom_domains.indexOf(parts[1]) >= 0) {
- // Address is Outlook.com
- if (options.outlookdotcom_remove_subaddress) {
- parts[0] = parts[0].split('+')[0];
- }
-
- if (!parts[0].length) {
- return false;
- }
-
- if (options.all_lowercase || options.outlookdotcom_lowercase) {
- parts[0] = parts[0].toLowerCase();
- }
- } else if (yahoo_domains.indexOf(parts[1]) >= 0) {
- // Address is Yahoo
- if (options.yahoo_remove_subaddress) {
- var components = parts[0].split('-');
- parts[0] = components.length > 1 ? components.slice(0, -1).join('-') : components[0];
- }
-
- if (!parts[0].length) {
- return false;
- }
-
- if (options.all_lowercase || options.yahoo_lowercase) {
- parts[0] = parts[0].toLowerCase();
- }
- } else if (yandex_domains.indexOf(parts[1]) >= 0) {
- if (options.all_lowercase || options.yandex_lowercase) {
- parts[0] = parts[0].toLowerCase();
- }
-
- parts[1] = 'yandex.ru'; // all yandex domains are equal, 1st preferred
- } else if (options.all_lowercase) {
- // Any other address
- parts[0] = parts[0].toLowerCase();
- }
-
- return parts.join('@');
-}
-
-var charsetRegex = /^[^\s-_](?!.*?[-_]{2,})([a-z0-9-\\]{1,})[^\s]*[^-_\s]$/;
-function isSlug(str) {
- assertString(str);
- return charsetRegex.test(str);
-}
-
-var upperCaseRegex = /^[A-Z]$/;
-var lowerCaseRegex = /^[a-z]$/;
-var numberRegex = /^[0-9]$/;
-var symbolRegex = /^[-#!$%^&*()_+|~=`{}\[\]:";'<>?,.\/ ]$/;
-var defaultOptions = {
- minLength: 8,
- minLowercase: 1,
- minUppercase: 1,
- minNumbers: 1,
- minSymbols: 1,
- returnScore: false,
- pointsPerUnique: 1,
- pointsPerRepeat: 0.5,
- pointsForContainingLower: 10,
- pointsForContainingUpper: 10,
- pointsForContainingNumber: 10,
- pointsForContainingSymbol: 10
-};
-/* Counts number of occurrences of each char in a string
- * could be moved to util/ ?
-*/
-
-function countChars(str) {
- var result = {};
- Array.from(str).forEach(function (_char) {
- var curVal = result[_char];
-
- if (curVal) {
- result[_char] += 1;
- } else {
- result[_char] = 1;
- }
- });
- return result;
-}
-/* Return information about a password */
-
-
-function analyzePassword(password) {
- var charMap = countChars(password);
- var analysis = {
- length: password.length,
- uniqueChars: Object.keys(charMap).length,
- uppercaseCount: 0,
- lowercaseCount: 0,
- numberCount: 0,
- symbolCount: 0
- };
- Object.keys(charMap).forEach(function (_char2) {
- if (upperCaseRegex.test(_char2)) {
- analysis.uppercaseCount += charMap[_char2];
- } else if (lowerCaseRegex.test(_char2)) {
- analysis.lowercaseCount += charMap[_char2];
- } else if (numberRegex.test(_char2)) {
- analysis.numberCount += charMap[_char2];
- } else if (symbolRegex.test(_char2)) {
- analysis.symbolCount += charMap[_char2];
- }
- });
- return analysis;
-}
-
-function scorePassword(analysis, scoringOptions) {
- var points = 0;
- points += analysis.uniqueChars * scoringOptions.pointsPerUnique;
- points += (analysis.length - analysis.uniqueChars) * scoringOptions.pointsPerRepeat;
-
- if (analysis.lowercaseCount > 0) {
- points += scoringOptions.pointsForContainingLower;
- }
-
- if (analysis.uppercaseCount > 0) {
- points += scoringOptions.pointsForContainingUpper;
- }
-
- if (analysis.numberCount > 0) {
- points += scoringOptions.pointsForContainingNumber;
- }
-
- if (analysis.symbolCount > 0) {
- points += scoringOptions.pointsForContainingSymbol;
- }
-
- return points;
-}
-
-function isStrongPassword(str) {
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
- assertString(str);
- var analysis = analyzePassword(str);
- options = merge(options || {}, defaultOptions);
-
- if (options.returnScore) {
- return scorePassword(analysis, options);
- }
-
- return analysis.length >= options.minLength && analysis.lowercaseCount >= options.minLowercase && analysis.uppercaseCount >= options.minUppercase && analysis.numberCount >= options.minNumbers && analysis.symbolCount >= options.minSymbols;
-}
-
-var vatMatchers = {
- GB: /^GB((\d{3} \d{4} ([0-8][0-9]|9[0-6]))|(\d{9} \d{3})|(((GD[0-4])|(HA[5-9]))[0-9]{2}))$/
-};
-function isVAT(str, countryCode) {
- assertString(str);
- assertString(countryCode);
-
- if (countryCode in vatMatchers) {
- return vatMatchers[countryCode].test(str);
- }
-
- throw new Error("Invalid country code: '".concat(countryCode, "'"));
-}
-
-var version = '13.5.0';
-var validator = {
- version: version,
- toDate: toDate,
- toFloat: toFloat,
- toInt: toInt,
- toBoolean: toBoolean,
- equals: equals,
- contains: contains,
- matches: matches,
- isEmail: isEmail,
- isURL: isURL,
- isMACAddress: isMACAddress,
- isIP: isIP,
- isIPRange: isIPRange,
- isFQDN: isFQDN,
- isBoolean: isBoolean,
- isIBAN: isIBAN,
- isBIC: isBIC,
- isAlpha: isAlpha,
- isAlphaLocales: locales$1,
- isAlphanumeric: isAlphanumeric,
- isAlphanumericLocales: locales$2,
- isNumeric: isNumeric,
- isPassportNumber: isPassportNumber,
- isPort: isPort,
- isLowercase: isLowercase,
- isUppercase: isUppercase,
- isAscii: isAscii,
- isFullWidth: isFullWidth,
- isHalfWidth: isHalfWidth,
- isVariableWidth: isVariableWidth,
- isMultibyte: isMultibyte,
- isSemVer: isSemVer,
- isSurrogatePair: isSurrogatePair,
- isInt: isInt,
- isIMEI: isIMEI,
- isFloat: isFloat,
- isFloatLocales: locales,
- isDecimal: isDecimal,
- isHexadecimal: isHexadecimal,
- isOctal: isOctal,
- isDivisibleBy: isDivisibleBy,
- isHexColor: isHexColor,
- isRgbColor: isRgbColor,
- isHSL: isHSL,
- isISRC: isISRC,
- isMD5: isMD5,
- isHash: isHash,
- isJWT: isJWT,
- isJSON: isJSON,
- isEmpty: isEmpty,
- isLength: isLength,
- isLocale: isLocale,
- isByteLength: isByteLength,
- isUUID: isUUID,
- isMongoId: isMongoId,
- isAfter: isAfter,
- isBefore: isBefore,
- isIn: isIn,
- isCreditCard: isCreditCard,
- isIdentityCard: isIdentityCard,
- isEAN: isEAN,
- isISIN: isISIN,
- isISBN: isISBN,
- isISSN: isISSN,
- isMobilePhone: isMobilePhone,
- isMobilePhoneLocales: locales$3,
- isPostalCode: isPostalCode,
- isPostalCodeLocales: locales$4,
- isEthereumAddress: isEthereumAddress,
- isCurrency: isCurrency,
- isBtcAddress: isBtcAddress,
- isISO8601: isISO8601,
- isRFC3339: isRFC3339,
- isISO31661Alpha2: isISO31661Alpha2,
- isISO31661Alpha3: isISO31661Alpha3,
- isBase32: isBase32,
- isBase58: isBase58,
- isBase64: isBase64,
- isDataURI: isDataURI,
- isMagnetURI: isMagnetURI,
- isMimeType: isMimeType,
- isLatLong: isLatLong,
- ltrim: ltrim,
- rtrim: rtrim,
- trim: trim,
- escape: escape,
- unescape: unescape,
- stripLow: stripLow,
- whitelist: whitelist,
- blacklist: blacklist$1,
- isWhitelisted: isWhitelisted,
- normalizeEmail: normalizeEmail,
- toString: toString,
- isSlug: isSlug,
- isStrongPassword: isStrongPassword,
- isTaxID: isTaxID,
- isDate: isDate,
- isVAT: isVAT
-};
-
-return validator;
-
-})));
diff --git a/validator.min.js b/validator.min.js
deleted file mode 100644
index 4d2b2ad3d..000000000
--- a/validator.min.js
+++ /dev/null
@@ -1,23 +0,0 @@
-/*!
- * Copyright (c) 2018 Chris O'Hara
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.validator=e()}(this,function(){"use strict";function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function h(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var r=[],n=!0,a=!1,i=void 0;try{for(var o,s=t[Symbol.iterator]();!(n=(o=s.next()).done)&&(r.push(o.value),!e||r.length!==e);n=!0);}catch(t){a=!0,i=t}finally{try{n||null==s.return||s.return()}finally{if(a)throw i}}return r}(t,e)||d(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||d(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(t,e){if(t){if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=e.min)&&(!e.hasOwnProperty("max")||n<=e.max)&&(!e.hasOwnProperty("lt")||ne.gt)}i["fr-CA"]=i["fr-FR"],s["fr-CA"]=s["fr-FR"],i["pt-BR"]=i["pt-PT"],s["pt-BR"]=s["pt-PT"],c["pt-BR"]=c["pt-PT"],i["pl-Pl"]=i["pl-PL"],s["pl-Pl"]=s["pl-PL"],c["pl-Pl"]=c["pl-PL"],i["fa-AF"]=i.fa;var C=Object.keys(c);function F(t){return E(t)?parseFloat(t):NaN}function _(t){return"object"===o(t)&&null!==t?t="function"==typeof t.toString?t.toString():"[object Object]":(null==t||isNaN(t)&&!t.length)&&(t=""),String(t)}function M(t,e){var r=0o)return!1;if("::"===t)return!0;"::"===t.substr(0,2)?(n.shift(),n.shift(),a=!0):"::"===t.substr(t.length-2)&&(n.pop(),n.pop(),a=!0);for(var s=0;s$/i,U=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,x=/^[a-z\d]+$/,P=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,G=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,O=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i;var Y={protocols:["http","https","ftp"],require_tld:!0,require_protocol:!1,require_host:!0,require_port:!1,require_valid_protocol:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_protocol_relative_urls:!1,validate_length:!0},k=/^\[([^\]]+)\](?::([0-9]+))?$/;function H(t,e){for(var r,n=0;n=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,s=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return o=t.done,t},e:function(t){s=!0,i=t},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw i}}}}(function(t,e){for(var r=[],n=Math.min(t.length,e.length),a=0;a=e.min,a=!e.hasOwnProperty("max")||t<=e.max,i=!e.hasOwnProperty("lt")||te.gt;return r.test(t)&&n&&a&&i&&o}var st=/^[0-9]{15}$/,ct=/^\d{2}-\d{6}-\d{6}-\d{1}$/;var lt=/^[\x00-\x7F]+$/;var ut=/[^\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/;var dt=/[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/;var ft=/[^\x00-\x7F]/;var pt,$t,At=(pt="i",$t=["^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)","(?:-((?:0|[1-9]\\d*|\\d*[a-z-][0-9a-z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-z-][0-9a-z-]*))*))","?(?:\\+([0-9a-z-]+(?:\\.[0-9a-z-]+)*))?$"].join(""),new RegExp($t,pt));var ht=/[\uD800-\uDBFF][\uDC00-\uDFFF]/;function gt(t,e){return t.some(function(t){return e===t})}var vt={force_decimal:!1,decimal_digits:"1,",locale:"en-US"},mt=["","-","+"];var It=/^(0x|0h)?[0-9A-F]+$/i;function St(t){return g(t),It.test(t)}var Zt=/^(0o)?[0-7]+$/i;var Et=/^#?([0-9A-F]{3}|[0-9A-F]{4}|[0-9A-F]{6}|[0-9A-F]{8})$/i;var Ct=/^rgb\((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]),){2}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\)$/,Ft=/^rgba\((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]),){3}(0?\.\d|1(\.0)?|0(\.0)?)\)$/,_t=/^rgb\((([0-9]%|[1-9][0-9]%|100%),){2}([0-9]%|[1-9][0-9]%|100%)\)/,Mt=/^rgba\((([0-9]%|[1-9][0-9]%|100%),){3}(0?\.\d|1(\.0)?|0(\.0)?)\)/;var Rt=/^(hsl)a?\(\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?))(deg|grad|rad|turn|\s*)(\s*,\s*(\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%){2}\s*(,\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%?)\s*)?\)$/i,bt=/^(hsl)a?\(\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?))(deg|grad|rad|turn|\s)(\s*(\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%){2}\s*(\/\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%?)\s*)?\)$/i;var Lt=/^[A-Z]{2}[0-9A-Z]{3}\d{2}\d{5}$/;var Nt={AD:/^(AD[0-9]{2})\d{8}[A-Z0-9]{12}$/,AE:/^(AE[0-9]{2})\d{3}\d{16}$/,AL:/^(AL[0-9]{2})\d{8}[A-Z0-9]{16}$/,AT:/^(AT[0-9]{2})\d{16}$/,AZ:/^(AZ[0-9]{2})[A-Z0-9]{4}\d{20}$/,BA:/^(BA[0-9]{2})\d{16}$/,BE:/^(BE[0-9]{2})\d{12}$/,BG:/^(BG[0-9]{2})[A-Z]{4}\d{6}[A-Z0-9]{8}$/,BH:/^(BH[0-9]{2})[A-Z]{4}[A-Z0-9]{14}$/,BR:/^(BR[0-9]{2})\d{23}[A-Z]{1}[A-Z0-9]{1}$/,BY:/^(BY[0-9]{2})[A-Z0-9]{4}\d{20}$/,CH:/^(CH[0-9]{2})\d{5}[A-Z0-9]{12}$/,CR:/^(CR[0-9]{2})\d{18}$/,CY:/^(CY[0-9]{2})\d{8}[A-Z0-9]{16}$/,CZ:/^(CZ[0-9]{2})\d{20}$/,DE:/^(DE[0-9]{2})\d{18}$/,DK:/^(DK[0-9]{2})\d{14}$/,DO:/^(DO[0-9]{2})[A-Z]{4}\d{20}$/,EE:/^(EE[0-9]{2})\d{16}$/,EG:/^(EG[0-9]{2})\d{25}$/,ES:/^(ES[0-9]{2})\d{20}$/,FI:/^(FI[0-9]{2})\d{14}$/,FO:/^(FO[0-9]{2})\d{14}$/,FR:/^(FR[0-9]{2})\d{10}[A-Z0-9]{11}\d{2}$/,GB:/^(GB[0-9]{2})[A-Z]{4}\d{14}$/,GE:/^(GE[0-9]{2})[A-Z0-9]{2}\d{16}$/,GI:/^(GI[0-9]{2})[A-Z]{4}[A-Z0-9]{15}$/,GL:/^(GL[0-9]{2})\d{14}$/,GR:/^(GR[0-9]{2})\d{7}[A-Z0-9]{16}$/,GT:/^(GT[0-9]{2})[A-Z0-9]{4}[A-Z0-9]{20}$/,HR:/^(HR[0-9]{2})\d{17}$/,HU:/^(HU[0-9]{2})\d{24}$/,IE:/^(IE[0-9]{2})[A-Z0-9]{4}\d{14}$/,IL:/^(IL[0-9]{2})\d{19}$/,IQ:/^(IQ[0-9]{2})[A-Z]{4}\d{15}$/,IR:/^(IR[0-9]{2})0\d{2}0\d{18}$/,IS:/^(IS[0-9]{2})\d{22}$/,IT:/^(IT[0-9]{2})[A-Z]{1}\d{10}[A-Z0-9]{12}$/,JO:/^(JO[0-9]{2})[A-Z]{4}\d{22}$/,KW:/^(KW[0-9]{2})[A-Z]{4}[A-Z0-9]{22}$/,KZ:/^(KZ[0-9]{2})\d{3}[A-Z0-9]{13}$/,LB:/^(LB[0-9]{2})\d{4}[A-Z0-9]{20}$/,LC:/^(LC[0-9]{2})[A-Z]{4}[A-Z0-9]{24}$/,LI:/^(LI[0-9]{2})\d{5}[A-Z0-9]{12}$/,LT:/^(LT[0-9]{2})\d{16}$/,LU:/^(LU[0-9]{2})\d{3}[A-Z0-9]{13}$/,LV:/^(LV[0-9]{2})[A-Z]{4}[A-Z0-9]{13}$/,MC:/^(MC[0-9]{2})\d{10}[A-Z0-9]{11}\d{2}$/,MD:/^(MD[0-9]{2})[A-Z0-9]{20}$/,ME:/^(ME[0-9]{2})\d{18}$/,MK:/^(MK[0-9]{2})\d{3}[A-Z0-9]{10}\d{2}$/,MR:/^(MR[0-9]{2})\d{23}$/,MT:/^(MT[0-9]{2})[A-Z]{4}\d{5}[A-Z0-9]{18}$/,MU:/^(MU[0-9]{2})[A-Z]{4}\d{19}[A-Z]{3}$/,NL:/^(NL[0-9]{2})[A-Z]{4}\d{10}$/,NO:/^(NO[0-9]{2})\d{11}$/,PK:/^(PK[0-9]{2})[A-Z0-9]{4}\d{16}$/,PL:/^(PL[0-9]{2})\d{24}$/,PS:/^(PS[0-9]{2})[A-Z0-9]{4}\d{21}$/,PT:/^(PT[0-9]{2})\d{21}$/,QA:/^(QA[0-9]{2})[A-Z]{4}[A-Z0-9]{21}$/,RO:/^(RO[0-9]{2})[A-Z]{4}[A-Z0-9]{16}$/,RS:/^(RS[0-9]{2})\d{18}$/,SA:/^(SA[0-9]{2})\d{2}[A-Z0-9]{18}$/,SC:/^(SC[0-9]{2})[A-Z]{4}\d{20}[A-Z]{3}$/,SE:/^(SE[0-9]{2})\d{20}$/,SI:/^(SI[0-9]{2})\d{15}$/,SK:/^(SK[0-9]{2})\d{20}$/,SM:/^(SM[0-9]{2})[A-Z]{1}\d{10}[A-Z0-9]{12}$/,SV:/^(SV[0-9]{2})[A-Z0-9]{4}\d{20}$/,TL:/^(TL[0-9]{2})\d{19}$/,TN:/^(TN[0-9]{2})\d{20}$/,TR:/^(TR[0-9]{2})\d{5}[A-Z0-9]{17}$/,UA:/^(UA[0-9]{2})\d{6}[A-Z0-9]{19}$/,VA:/^(VA[0-9]{2})\d{18}$/,VG:/^(VG[0-9]{2})[A-Z0-9]{4}\d{16}$/,XK:/^(XK[0-9]{2})\d{16}$/};var Dt=/^[A-z]{4}[A-z]{2}\w{2}(\w{3})?$/;var Tt=/^[a-f0-9]{32}$/;var wt={md5:32,md4:32,sha1:40,sha256:64,sha384:96,sha512:128,ripemd128:32,ripemd160:40,tiger128:32,tiger160:40,tiger192:48,crc32:8,crc32b:8};var yt=/[^A-Z0-9+\/=]/i,Bt=/^[A-Z0-9_\-]*$/i,Ut={urlSafe:!1};function xt(t,e){g(t),e=M(e,Ut);var r=t.length;if(e.urlSafe)return Bt.test(t);if(r%4!=0||yt.test(t))return!1;var n=t.indexOf("=");return-1===n||n===r-1||n===r-2&&"="===t[r-1]}var Pt={allow_primitives:!1};var Gt={ignore_whitespace:!1};var Ot={3:/^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,4:/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,5:/^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,all:/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i};var Yt=/^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14})$/;var kt={ES:function(t){g(t);var e={X:0,Y:1,Z:2},r=t.trim().toUpperCase();if(!/^[0-9X-Z][0-9]{7}[TRWAGMYFPDXBNJZSQVHLCKE]$/.test(r))return!1;var n=r.slice(0,-1).replace(/[X,Y,Z]/g,function(t){return e[t]});return r.endsWith(["T","R","W","A","G","M","Y","F","P","D","X","B","N","J","Z","S","Q","V","H","L","C","K","E"][n%23])},IN:function(t){var r=[[0,1,2,3,4,5,6,7,8,9],[1,2,3,4,0,6,7,8,9,5],[2,3,4,0,1,7,8,9,5,6],[3,4,0,1,2,8,9,5,6,7],[4,0,1,2,3,9,5,6,7,8],[5,9,8,7,6,0,4,3,2,1],[6,5,9,8,7,1,0,4,3,2],[7,6,5,9,8,2,1,0,4,3],[8,7,6,5,9,3,2,1,0,4],[9,8,7,6,5,4,3,2,1,0]],n=[[0,1,2,3,4,5,6,7,8,9],[1,5,7,6,2,8,3,0,9,4],[5,8,0,3,7,9,6,1,4,2],[8,9,1,6,0,4,3,5,2,7],[9,4,5,3,1,2,6,8,7,0],[4,2,8,6,5,7,3,9,0,1],[2,7,9,3,8,0,6,4,1,5],[7,0,4,6,9,1,3,2,5,8]],e=t.trim();if(!/^[1-9]\d{3}\s?\d{4}\s?\d{4}$/.test(e))return!1;var a=0;return e.replace(/\s/g,"").split("").map(Number).reverse().forEach(function(t,e){a=r[a][n[e%8][t]]}),0===a},IT:function(t){return 9===t.length&&("CA00000AA"!==t&&-1new Date)&&(a.getFullYear()===e&&a.getMonth()===r-1&&a.getDate()===n)}function o(t){return function(t){for(var e=t.substring(0,17),r=0,n=0;n<17;n++)r+=parseInt(e.charAt(n),10)*parseInt(s[n],10);return c[r%11]}(t)===t.charAt(17).toUpperCase()}var e,r=["11","12","13","14","15","21","22","23","31","32","33","34","35","36","37","41","42","43","44","45","46","50","51","52","53","54","61","62","63","64","65","71","81","82","91"],s=["7","9","10","5","8","4","2","1","6","3","7","9","10","5","8","4","2"],c=["1","0","X","9","8","7","6","5","4","3","2"];return!!/^\d{15}|(\d{17}(\d|x|X))$/.test(e=t)&&(15===e.length?function(t){var e=/^[1-9]\d{7}((0[1-9])|(1[0-2]))((0[1-9])|([1-2][0-9])|(3[0-1]))\d{3}$/.test(t);if(!e)return!1;var r=t.substring(0,2);if(!(e=a(r)))return!1;var n="19".concat(t.substring(6,12));return!!(e=i(n))}:function(t){var e=/^[1-9]\d{5}[1-9]\d{3}((0[1-9])|(1[0-2]))((0[1-9])|([1-2][0-9])|(3[0-1]))\d{3}(\d|x|X)$/.test(t);if(!e)return!1;var r=t.substring(0,2);if(!(e=a(r)))return!1;var n=t.substring(6,14);return!!(e=i(n))&&o(t)})(e)},"zh-TW":function(t){var a={A:10,B:11,C:12,D:13,E:14,F:15,G:16,H:17,I:34,J:18,K:19,L:20,M:21,N:22,O:35,P:23,Q:24,R:25,S:26,T:27,U:28,V:29,W:32,X:30,Y:31,Z:33},e=t.trim().toUpperCase();return!!/^[A-Z][0-9]{9}$/.test(e)&&Array.from(e).reduce(function(t,e,r){if(0!==r)return 9===r?(10-t%10-Number(e))%10==0:t+Number(e)*(9-r);var n=a[e];return n%10*9+Math.floor(n/10)},0)}};var Ht=8,Kt=/^(\d{8}|\d{13})$/;function Vt(a){var t=10-a.slice(0,-1).split("").map(function(t,e){return Number(t)*(r=a.length,n=e,r===Ht?n%2==0?3:1:n%2==0?1:3);var r,n}).reduce(function(t,e){return t+e},0)%10;return t<10?t:0}var Wt=/^[A-Z]{2}[0-9A-Z]{9}[0-9]$/;var zt=/^(?:[0-9]{9}X|[0-9]{10})$/,jt=/^(?:[0-9]{13})$/,Jt=[1,3];function Xt(t){for(var e=10,r=0;ri?"".concat(o-1).concat(r):"".concat(o).concat(r);else if(r="".concat(o-1).concat(r),i-parseInt(r,10)<100)return!1}60?,.\/ ]$/,rr={minLength:8,minLowercase:1,minUppercase:1,minNumbers:1,minSymbols:1,returnScore:!1,pointsPerUnique:1,pointsPerRepeat:.5,pointsForContainingLower:10,pointsForContainingUpper:10,pointsForContainingNumber:10,pointsForContainingSymbol:10};function nr(t){var e,r,n=(e=t,r={},Array.from(e).forEach(function(t){r[t]?r[t]+=1:r[t]=1}),r),a={length:t.length,uniqueChars:Object.keys(n).length,uppercaseCount:0,lowercaseCount:0,numberCount:0,symbolCount:0};return Object.keys(n).forEach(function(t){qe.test(t)?a.uppercaseCount+=n[t]:Qe.test(t)?a.lowercaseCount+=n[t]:tr.test(t)?a.numberCount+=n[t]:er.test(t)&&(a.symbolCount+=n[t])}),a}var ar={GB:/^GB((\d{3} \d{4} ([0-8][0-9]|9[0-6]))|(\d{9} \d{3})|(((GD[0-4])|(HA[5-9]))[0-9]{2}))$/};return{version:"13.5.0",toDate:a,toFloat:F,toInt:function(t,e){return g(t),parseInt(t,e||10)},toBoolean:function(t,e){return g(t),e?"1"===t||/^true$/i.test(t):"0"!==t&&!/^false$/i.test(t)&&""!==t},equals:function(t,e){return g(t),t===e},contains:function(t,e,r){return g(t),(r=M(r,R)).ignoreCase?0<=t.toLowerCase().indexOf(_(e).toLowerCase()):0<=t.indexOf(_(e))},matches:function(t,e,r){return g(t),"[object RegExp]"!==Object.prototype.toString.call(e)&&(e=new RegExp(e,r)),e.test(t)},isEmail:function(t,e){if(g(t),(e=M(e,y)).require_display_name||e.allow_display_name){var r=t.match(B);if(r){var n=h(r,3),a=n[1];if(t=n[2],a.endsWith(" ")&&(a=a.substr(0,a.length-1)),!function(t){var e=t.match(/^"(.+)"$/i),r=e?e[1]:t;if(r.trim()){if(/[\.";<>]/.test(r)){if(!e)return;if(!(r.split('"').length===r.split('\\"').length))return}return 1}}(a))return!1}else if(e.require_display_name)return!1}if(!e.ignore_max_length&&254]/.test(t))return!1;if(0===t.indexOf("mailto:"))return!1;if((e=M(e,Y)).validate_length&&2083<=t.length)return!1;var r,n,a,i,o,s,c,l=t.split("#");if(1<(l=(t=(l=(t=l.shift()).split("?")).shift()).split("://")).length){if(r=l.shift().toLowerCase(),e.require_valid_protocol&&-1===e.protocols.indexOf(r))return!1}else{if(e.require_protocol)return!1;if("//"===t.substr(0,2)){if(!e.allow_protocol_relative_urls)return!1;l[0]=t.substr(2)}}if(""===(t=l.join("://")))return!1;if(""===(t=(l=t.split("/")).shift())&&!e.require_host)return!0;if(1<(l=t.split("@")).length){if(e.disallow_auth)return!1;if(-1===(n=l.shift()).indexOf(":")||0<=n.indexOf(":")&&2/g,">").replace(/\//g,"/").replace(/\\/g,"\").replace(/`/g,"`")},unescape:function(t){return g(t),t.replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(///g,"/").replace(/\/g,"\\").replace(/`/g,"`")},stripLow:function(t,e){return g(t),He(t,e?"\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F":"\\x00-\\x1F\\x7F")},whitelist:function(t,e){return g(t),t.replace(new RegExp("[^".concat(e,"]+"),"g"),"")},blacklist:He,isWhitelisted:function(t,e){g(t);for(var r=t.length-1;0<=r;r--)if(-1===e.indexOf(t[r]))return!1;return!0},normalizeEmail:function(t,e){e=M(e,Ke);var r,n=t.split("@"),a=n.pop(),i=[n.join("@"),a];if(i[1]=i[1].toLowerCase(),"gmail.com"===i[1]||"googlemail.com"===i[1]){if(e.gmail_remove_subaddress&&(i[0]=i[0].split("+")[0]),e.gmail_remove_dots&&(i[0]=i[0].replace(/\.+/g,Je)),!i[0].length)return!1;(e.all_lowercase||e.gmail_lowercase)&&(i[0]=i[0].toLowerCase()),i[1]=e.gmail_convert_googlemaildotcom?"gmail.com":i[1]}else if(0<=Ve.indexOf(i[1])){if(e.icloud_remove_subaddress&&(i[0]=i[0].split("+")[0]),!i[0].length)return!1;(e.all_lowercase||e.icloud_lowercase)&&(i[0]=i[0].toLowerCase())}else if(0<=We.indexOf(i[1])){if(e.outlookdotcom_remove_subaddress&&(i[0]=i[0].split("+")[0]),!i[0].length)return!1;(e.all_lowercase||e.outlookdotcom_lowercase)&&(i[0]=i[0].toLowerCase())}else if(0<=ze.indexOf(i[1])){if(e.yahoo_remove_subaddress&&(r=i[0].split("-"),i[0]=1=e.minLength&&i.lowercaseCount>=e.minLowercase&&i.uppercaseCount>=e.minUppercase&&i.numberCount>=e.minNumbers&&i.symbolCount>=e.minSymbols},isTaxID:function(t){var e=1