Skip to content

Commit c84f6b9

Browse files
committed
Merge remote-tracking branch 'main/master' into sgress454/update-is-url-docs
2 parents c997eaa + bdb8f9e commit c84f6b9

16 files changed

Lines changed: 162 additions & 33 deletions

.github/workflows/ci.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,24 @@ on:
66
branches: [master]
77
jobs:
88
test:
9-
runs-on: ubuntu-20.04
9+
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
node-version: [20, 18, 16, 14, 12, 10, 8, 6]
12+
node-version: [22, 20, 18, 16, 14, 12, 10, 8, 6]
1313
name: Run tests on Node.js ${{ matrix.node-version }}
1414
steps:
1515
- name: Setup Node.js ${{ matrix.node-version }}
16-
uses: actions/setup-node@v2-beta
16+
uses: actions/setup-node@v4
1717
with:
1818
node-version: ${{ matrix.node-version }}
19-
check-latest: true
2019
- name: Checkout repository
21-
uses: actions/checkout@v2
20+
uses: actions/checkout@v4
2221
- name: Install dependencies
23-
run: npm install --legacy-peer-deps
22+
run: npm install --legacy-peer-deps
2423
- name: Run tests
2524
run: npm test
26-
- if: matrix.node-version == 20
25+
- if: matrix.node-version == 22
2726
name: Send coverage info to Codecov
28-
uses: codecov/codecov-action@v1
27+
uses: codecov/codecov-action@v5
2928
with:
30-
file: ./coverage/cobertura-coverage.xml
29+
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ jobs:
3838

3939
steps:
4040
- name: Checkout repository
41-
uses: actions/checkout@v2
41+
uses: actions/checkout@v4
4242

4343
# Initializes the CodeQL tools for scanning.
4444
- name: Initialize CodeQL
45-
uses: github/codeql-action/init@v2
45+
uses: github/codeql-action/init@v3
4646
with:
4747
languages: ${{ matrix.language }}
4848
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -53,7 +53,7 @@ jobs:
5353
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5454
# If this step fails, then you should remove it and run the build manually (see below)
5555
- name: Autobuild
56-
uses: github/codeql-action/autobuild@v2
56+
uses: github/codeql-action/autobuild@v3
5757

5858
# ℹ️ Command-line programs to run using the OS shell.
5959
# 📚 https://git.io/JvXDl
@@ -67,4 +67,4 @@ jobs:
6767
# make release
6868

6969
- name: Perform CodeQL Analysis
70-
uses: github/codeql-action/analyze@v2
70+
uses: github/codeql-action/analyze@v3

.github/workflows/npm-publish.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,20 @@ on:
44
types: [created]
55
jobs:
66
publish:
7-
runs-on: ubuntu-20.04
7+
runs-on: ubuntu-latest
88
permissions:
99
contents: read
1010
id-token: write
1111
steps:
12-
- name: Setup Node.js 18
13-
uses: actions/setup-node@v3
12+
- name: Setup Node.js 22
13+
uses: actions/setup-node@v4
1414
with:
15-
node-version: 18
16-
check-latest: true
15+
node-version: 22
1716
registry-url: https://registry.npmjs.org/
1817
- name: Checkout Repository
19-
uses: actions/checkout@v3
18+
uses: actions/checkout@v4
2019
- name: Install Dependencies
21-
run: npm install
20+
run: npm install --legacy-peer-deps
2221
- name: Run Tests
2322
run: npm test
2423
- name: Publish Package to NPM Registry

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Validator | Description
157157
**isOctal(str)** | check if the string is a valid octal number.
158158
**isPassportNumber(str, countryCode)** | check if the string is a valid passport number.<br/><br/>`countryCode` is one of `['AM', 'AR', 'AT', 'AU', 'AZ', 'BE', 'BG', 'BY', 'BR', 'CA', 'CH', 'CN', 'CY', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE', 'IN', 'IR', 'ID', 'IS', 'IT', 'JM', 'JP', 'KR', 'KZ', 'LI', 'LT', 'LU', 'LV', 'LY', 'MT', 'MX', 'MY', 'MZ', 'NL', 'NZ', 'PH', 'PK', 'PL', 'PT', 'RO', 'RU', 'SE', 'SL', 'SK', 'TH', 'TR', 'UA', 'US', 'ZA']`. Locale list is `validator.passportNumberLocales`.
159159
**isPort(str)** | check if the string is a valid port number.
160-
**isPostalCode(str, locale)** | check if the string is a postal code.<br/><br/>`locale` is one of `['AD', 'AT', 'AU', 'AZ', 'BA', 'BE', 'BG', 'BR', 'BY', 'CA', 'CH', 'CN', 'CO', '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', 'LK', 'LT', 'LU', 'LV', 'MG', 'MT', 'MX', 'MY', 'NL', 'NO', 'NP', 'NZ', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SG', 'SI', 'SK', 'TH', 'TN', 'TW', 'UA', 'US', 'ZA', 'ZM']` OR `'any'`. If 'any' is used, function will check if any of the locales match. Locale list is `validator.isPostalCodeLocales`.
160+
**isPostalCode(str, locale)** | check if the string is a postal code.<br/><br/>`locale` is one of `['AD', 'AT', 'AU', 'AZ', 'BA', 'BE', 'BG', 'BR', 'BY', 'CA', 'CH', 'CN', 'CO', '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', 'LK', 'LT', 'LU', 'LV', 'MG', 'MT', 'MX', 'MY', 'NL', 'NO', 'NP', 'NZ', 'PK', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SG', 'SI', 'SK', 'TH', 'TN', 'TW', 'UA', 'US', 'ZA', 'ZM']` OR `'any'`. If 'any' is used, function will check if any of the locales match. Locale list is `validator.isPostalCodeLocales`.
161161
**isRFC3339(str)** | check if the string is a valid [RFC 3339][RFC 3339] date.
162162
**isRgbColor(str [,options])** | check if the string is a rgb or rgba color.<br/></br>`options` is an object with the following properties<br/><br/>`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.<br/><br/>`allowSpaces` defaults to `true`, which prohibits whitespace. If set to false, whitespace between color values is allowed, such as `rgb(255, 255, 255)` or even `rgba(255, 128, 0, 0.7)`.
163163
**isSemVer(str)** | check if the string is a Semantic Versioning Specification (SemVer).

src/lib/isBoolean.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import assertString from './util/assertString';
2+
import includes from './util/includesArray';
23

34
const defaultOptions = { loose: false };
45
const strictBooleans = ['true', 'false', '1', '0'];
@@ -8,8 +9,8 @@ export default function isBoolean(str, options = defaultOptions) {
89
assertString(str);
910

1011
if (options.loose) {
11-
return looseBooleans.includes(str.toLowerCase());
12+
return includes(looseBooleans, str.toLowerCase());
1213
}
1314

14-
return strictBooleans.includes(str);
15+
return includes(strictBooleans, str);
1516
}

src/lib/isDecimal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import merge from './util/merge';
22
import assertString from './util/assertString';
3-
import includes from './util/includes';
3+
import includes from './util/includesArray';
44
import { decimal } from './alpha';
55

66
function decimalRegExp(options) {

src/lib/isIBAN.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import assertString from './util/assertString';
2+
import includes from './util/includesArray';
23

34
/**
45
* List of country codes with
@@ -131,15 +132,15 @@ function hasValidIbanFormat(str, options) {
131132
return false;
132133
}
133134

134-
const isoCountryCodeInWhiteList = options.whitelist.includes(isoCountryCode);
135+
const isoCountryCodeInWhiteList = includes(options.whitelist, isoCountryCode);
135136

136137
if (!isoCountryCodeInWhiteList) {
137138
return false;
138139
}
139140
}
140141

141142
if (options.blacklist) {
142-
const isoCountryCodeInBlackList = options.blacklist.includes(isoCountryCode);
143+
const isoCountryCodeInBlackList = includes(options.blacklist, isoCountryCode);
143144

144145
if (isoCountryCodeInBlackList) {
145146
return false;

src/lib/isIdentityCard.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import assertString from './util/assertString';
2+
import includes from './util/includesArray';
23
import isInt from './isInt';
34

45
const validators = {
@@ -277,7 +278,7 @@ const validators = {
277278

278279
const parityBit = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
279280

280-
const checkAddressCode = addressCode => provincesAndCities.includes(addressCode);
281+
const checkAddressCode = addressCode => includes(provincesAndCities, addressCode);
281282

282283
const checkBirthDayCode = (birDayCode) => {
283284
const yyyy = parseInt(birDayCode.substring(0, 4), 10);

src/lib/isJSON.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import assertString from './util/assertString';
2+
import includes from './util/includesArray';
23
import merge from './util/merge';
34

45
const default_json_options = {
@@ -15,7 +16,7 @@ export default function isJSON(str, options) {
1516
}
1617

1718
const obj = JSON.parse(str);
18-
return primitives.includes(obj) || (!!obj && typeof obj === 'object');
19+
return includes(primitives, obj) || (!!obj && typeof obj === 'object');
1920
} catch (e) { /* ignore */ }
2021
return false;
2122
}

src/lib/isLatLong.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import assertString from './util/assertString';
22
import merge from './util/merge';
3+
import includes from './util/includesString';
34

45
const lat = /^\(?[+-]?(90(\.0+)?|[1-8]?\d(\.\d+)?)$/;
56
const long = /^\s?[+-]?(180(\.0+)?|1[0-7]\d(\.\d+)?|\d{1,2}(\.\d+)?)\)?$/;
@@ -15,7 +16,7 @@ export default function isLatLong(str, options) {
1516
assertString(str);
1617
options = merge(options, defaultLatLongOptions);
1718

18-
if (!str.includes(',')) return false;
19+
if (!includes(str, ',')) return false;
1920
const pair = str.split(',');
2021
if ((pair[0].startsWith('(') && !pair[1].endsWith(')'))
2122
|| (pair[1].endsWith(')') && !pair[0].startsWith('('))) return false;

0 commit comments

Comments
 (0)