Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maintenance: 2405 release #2269

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2c4aede
fix(isDate): Timezone Offset Fix (#2257)
tomaspanek Aug 18, 2023
3541b0d
feat(isTaxId): add tax id for Argentina, es-AR (#2224)
estefrare Aug 18, 2023
6923860
feat(isPassportNumber): added South African, ZA validator (#2265)
GMorris-professional Aug 18, 2023
b958bd7
feat(isMobilePhone): Added the regex for Malawi en-MW (#2267)
SimranSiddiqui Aug 18, 2023
332b501
fix(docs): misspelling of Mailto (#2368)
ZhulinskiiDanil Mar 5, 2024
4197b86
chore(isMailtoURI): remove unnecessary default to (#2341)
WikiRik Mar 5, 2024
31c88cf
fix(docs): fixed typo in README.md (#2371)
devmanbud Apr 25, 2024
6d5c52a
feat(isUUID): support uuid v7 (#2345)
ruscon Apr 25, 2024
752bd09
fix(isPassportNumber): fix regex Azerbaijan (#2284)
amaliacatalina Apr 25, 2024
0a100fe
feat(isAlpha, isAlphanumeric): add Esperanto (eo) locale (#2285)
RobinvanderVliet Apr 25, 2024
edb6b1c
fix(isPostalCode): improve Dutch postal code regex (#2271)
RobinvanderVliet Apr 25, 2024
b34a335
fix(isPort): Invalid leading zeros (#2208)
anasshakil Apr 25, 2024
32b174e
feat(isLicensePlate): Support for Pakistani vehicles (#2207)
anasshakil Apr 25, 2024
19f11cf
feat: added isAbaRouting validator (#2143)
songyuew Apr 25, 2024
6b3f62d
fix(isMobilePhone): fixed validation for am-AM (#2140)
AlexKrupko Apr 25, 2024
817e56e
ci: add latest node versions (#2364)
rubiin Apr 25, 2024
72c8dc1
fix(isPassport): added tests for ZA Passport Number (#2270)
GMorris-professional Apr 27, 2024
5677f91
fix: add SLE to the isISO4217 validator (#2273)
urg Apr 27, 2024
2253a77
chore: Publish to NPM with provenance (#2276)
meyfa Apr 27, 2024
8a40349
fix: symbolRegex in isStrongPassword to include '\' (#2278)
nandavikas Apr 27, 2024
11ac6a4
fix(isVAT): fixed KZ VAT number length check (#2279)
MatthieuLemoine Apr 27, 2024
d8c93d2
feat(isIBAN): add Algeria locale (#2320)
thibault-lr Apr 27, 2024
eacccaf
docs: move contributing guidelines to CONTRIBUTING.md (#2386)
alinaghale88 Apr 27, 2024
0836777
fix(isDate): hyphen before year is not allowed (#2381)
Sumit-tech-joshi Apr 27, 2024
43a0f09
feat(isTaxID): added TaxID for Ukraine uk-UA (#2358)
arttiger Apr 27, 2024
83d6ffd
fix(isVAT): improved ABN (AU VAT) validation (#2343)
matthewberryman Apr 27, 2024
cd4e7bf
13.12.0
profnandaa May 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [14, 12, 10, 8, 6]
node-version: [20, 18, 16, 14, 12, 10, 8, 6]
name: Run tests on Node.js ${{ matrix.node-version }}
steps:
- name: Setup Node.js ${{ matrix.node-version }}
Expand All @@ -20,10 +20,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install dependencies
run: npm install
run: npm install --legacy-peer-deps
- name: Run tests
run: npm test
- if: matrix.node-version == 14
- if: matrix.node-version == 20
name: Send coverage info to Codecov
uses: codecov/codecov-action@v1
with:
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@ on:
jobs:
publish:
runs-on: ubuntu-20.04
permissions:
contents: read
id-token: write
steps:
- name: Setup Node.js 14
uses: actions/setup-node@v2-beta
- name: Setup Node.js 18
uses: actions/setup-node@v3
with:
node-version: 14
node-version: 18
check-latest: true
registry-url: https://registry.npmjs.org/
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install Dependencies
run: npm install
- name: Run Tests
run: npm test
- name: Publish Package to NPM Registry
run: npm publish
run: npm publish --provenance
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_SECRET}}
17 changes: 9 additions & 8 deletions README.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"rimraf": "^3.0.0",
"rollup": "^0.47.0",
"rollup-plugin-babel": "^4.0.1",
"timezone-mock": "^1.3.6",
"uglify-js": "^3.0.19"
},
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import isTime from './lib/isTime';
import isBoolean from './lib/isBoolean';
import isLocale from './lib/isLocale';

import isAbaRouting from './lib/isAbaRouting';
import isAlpha, { locales as isAlphaLocales } from './lib/isAlpha';
import isAlphanumeric, { locales as isAlphanumericLocales } from './lib/isAlphanumeric';
import isNumeric from './lib/isNumeric';
Expand Down Expand Up @@ -146,6 +147,7 @@ const validator = {
isBoolean,
isIBAN,
isBIC,
isAbaRouting,
isAlpha,
isAlphaLocales,
isAlphanumeric,
Expand Down
4 changes: 3 additions & 1 deletion src/lib/alpha.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const alpha = {
he: /^[א-ת]+$/,
fa: /^['آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی']+$/i,
bn: /^['ঀঁংঃঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহ়ঽািীুূৃৄেৈোৌ্ৎৗড়ঢ়য়ৠৡৢৣৰৱ৲৳৴৵৶৷৸৹৺৻']+$/,
eo: /^[ABCĈD-GĜHĤIJĴK-PRSŜTUŬVZ]+$/i,
'hi-IN': /^[\u0900-\u0961]+[\u0972-\u097F]*$/i,
'si-LK': /^[\u0D80-\u0DFF]+$/,
};
Expand Down Expand Up @@ -75,6 +76,7 @@ export const alphanumeric = {
he: /^[0-9א-ת]+$/,
fa: /^['0-9آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی۱۲۳۴۵۶۷۸۹۰']+$/i,
bn: /^['ঀঁংঃঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহ়ঽািীুূৃৄেৈোৌ্ৎৗড়ঢ়য়ৠৡৢৣ০১২৩৪৫৬৭৮৯ৰৱ৲৳৴৵৶৷৸৹৺৻']+$/,
eo: /^[0-9ABCĈD-GĜHĤIJĴK-PRSŜTUŬVZ]+$/i,
'hi-IN': /^[\u0900-\u0963]+[\u0966-\u097F]*$/i,
'si-LK': /^[0-9\u0D80-\u0DFF]+$/,
};
Expand Down Expand Up @@ -125,7 +127,7 @@ for (let locale, i = 0; i < bengaliLocales.length; i++) {
// Source: https://en.wikipedia.org/wiki/Decimal_mark
export const dotDecimal = ['ar-EG', 'ar-LB', 'ar-LY'];
export const commaDecimal = [
'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-ZM', 'es-ES', 'fr-CA', 'fr-FR',
'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-ZM', 'eo', 'es-ES', 'fr-CA', 'fr-FR',
'id-ID', 'it-IT', 'ku-IQ', 'hi-IN', 'hu-HU', 'nb-NO', 'nn-NO', 'nl-NL', 'pl-PL', 'pt-PT',
'ru-RU', 'kk-KZ', 'si-LK', 'sl-SI', 'sr-RS@latin', 'sr-RS', 'sv-SE', 'tr-TR', 'uk-UA', 'vi-VN',
];
Expand Down
20 changes: 20 additions & 0 deletions src/lib/isAbaRouting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import assertString from './util/assertString';

// http://www.brainjar.com/js/validation/
// https://www.aba.com/news-research/research-analysis/routing-number-policy-procedures
// series reserved for future use are excluded
const isRoutingReg = /^(?!(1[3-9])|(20)|(3[3-9])|(4[0-9])|(5[0-9])|(60)|(7[3-9])|(8[1-9])|(9[0-2])|(9[3-9]))[0-9]{9}$/;

export default function isAbaRouting(str) {
assertString(str);

if (!isRoutingReg.test(str)) return false;

let checkSumVal = 0;
for (let i = 0; i < str.length; i++) {
if (i % 3 === 0) checkSumVal += str[i] * 3;
else if (i % 3 === 1) checkSumVal += str[i] * 7;
else checkSumVal += str[i] * 1;
}
return (checkSumVal % 10 === 0);
}
14 changes: 13 additions & 1 deletion src/lib/isDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,19 @@ export default function isDate(input, options) {
}
}

return new Date(`${fullYear}-${dateObj.m}-${dateObj.d}`).getDate() === +dateObj.d;
let month = dateObj.m;

if (dateObj.m.length === 1) {
month = `0${dateObj.m}`;
}

let day = dateObj.d;

if (dateObj.d.length === 1) {
day = `0${dateObj.d}`;
}

return new Date(`${fullYear}-${month}-${day}T00:00:00.000Z`).getUTCDate() === +dateObj.d;
}

if (!options.strictMode) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/isISO4217.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const validISO4217CurrencyCodes = new Set([
'PAB', 'PEN', 'PGK', 'PHP', 'PKR', 'PLN', 'PYG',
'QAR',
'RON', 'RSD', 'RUB', 'RWF',
'SAR', 'SBD', 'SCR', 'SDG', 'SEK', 'SGD', 'SHP', 'SLL', 'SOS', 'SRD', 'SSP', 'STN', 'SVC', 'SYP', 'SZL',
'SAR', 'SBD', 'SCR', 'SDG', 'SEK', 'SGD', 'SHP', 'SLE', 'SLL', 'SOS', 'SRD', 'SSP', 'STN', 'SVC', 'SYP', 'SZL',
'THB', 'TJS', 'TMT', 'TND', 'TOP', 'TRY', 'TTD', 'TWD', 'TZS',
'UAH', 'UGX', 'USD', 'USN', 'UYI', 'UYU', 'UYW', 'UZS',
'VES', 'VND', 'VUV',
Expand Down
5 changes: 1 addition & 4 deletions src/lib/isInt.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ export default function isInt(str, options) {

// Get the regex to use for testing, based on whether
// leading zeroes are allowed or not.
let regex = (
options.hasOwnProperty('allow_leading_zeroes') && !options.allow_leading_zeroes ?
int : intLeadingZeroes
);
const regex = options.allow_leading_zeroes === false ? int : intLeadingZeroes;

// Check min/max/lt/gt
let minCheckPassed = (!options.hasOwnProperty('min') || str >= options.min);
Expand Down
1 change: 1 addition & 0 deletions src/lib/isLicensePlate.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/lib/isMailtoURI.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function isMailtoURI(url, options) {
return false;
}

const [to = '', queryString = ''] = url.replace('mailto:', '').split('?');
const [to, queryString = ''] = url.replace('mailto:', '').split('?');

if (!to && !queryString) {
return true;
Expand Down
3 changes: 2 additions & 1 deletion src/lib/isMobilePhone.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import assertString from './util/assertString';

/* eslint-disable max-len */
const phones = {
'am-AM': /^(\+?374|0)((10|[9|7][0-9])\d{6}$|[2-4]\d{7}$)/,
'am-AM': /^(\+?374|0)(33|4[134]|55|77|88|9[13-689])\d{6}$/,
'ar-AE': /^((\+?971)|0)?5[024568]\d{7}$/,
'ar-BH': /^(\+?973)?(3|6)\d{7}$/,
'ar-DZ': /^(\+?213|0)(5|6|7)\d{8}$/,
Expand Down Expand Up @@ -56,6 +56,7 @@ const phones = {
'en-LS': /^(\+?266)(22|28|57|58|59|27|52)\d{6}$/,
'en-MT': /^(\+?356|0)?(99|79|77|21|27|22|25)[0-9]{6}$/,
'en-MU': /^(\+?230|0)?\d{8}$/,
'en-MW': /^(\+?265|0)(((77|88|31|99|98|21)\d{7})|(((111)|1)\d{6})|(32000\d{4}))$/,
'en-NA': /^(\+?264|0)(6|8)\d{7}$/,
'en-NG': /^(\+?234|0)?[789]\d{9}$/,
'en-NZ': /^(\+?64|0)[28]\d{7,9}$/,
Expand Down
3 changes: 2 additions & 1 deletion src/lib/isPassportNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const passportRegexByCountryCode = {
AR: /^[A-Z]{3}\d{6}$/, // ARGENTINA
AT: /^[A-Z]\d{7}$/, // AUSTRIA
AU: /^[A-Z]\d{7}$/, // AUSTRALIA
AZ: /^[A-Z]{2,3}\d{7,8}$/, // AZERBAIJAN
AZ: /^[A-Z]{1}\d{8}$/, // AZERBAIJAN
BE: /^[A-Z]{2}\d{6}$/, // BELGIUM
BG: /^\d{9}$/, // BULGARIA
BR: /^[A-Z]{2}\d{6}$/, // BRAZIL
Expand Down Expand Up @@ -66,6 +66,7 @@ const passportRegexByCountryCode = {
TR: /^[A-Z]\d{8}$/, // TURKEY
UA: /^[A-Z]{2}\d{6}$/, // UKRAINE
US: /^\d{9}$/, // UNITED STATES
ZA: /^[TAMD]\d{8}$/, // SOUTH AFRICA
profnandaa marked this conversation as resolved.
Show resolved Hide resolved
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/isPort.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import isInt from './isInt';

export default function isPort(str) {
return isInt(str, { min: 0, max: 65535 });
return isInt(str, { allow_leading_zeroes: false, min: 0, max: 65535 });
}
2 changes: 1 addition & 1 deletion src/lib/isPostalCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const patterns = {
MX: fiveDigit,
MT: /^[A-Za-z]{3}\s{0,1}\d{4}$/,
MY: fiveDigit,
NL: /^\d{4}\s?[a-z]{2}$/i,
NL: /^[1-9]\d{3}\s?(?!sa|sd|ss)[a-z]{2}$/i,
NO: fourDigit,
NP: /^(10|21|22|32|33|34|44|45|56|57)\d{3}$|^(977)$/i,
NZ: fourDigit,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/isStrongPassword.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
26 changes: 26 additions & 0 deletions src/lib/isTaxID.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,30 @@ function enUsCheck(tin) {
return enUsGetPrefixes().indexOf(tin.slice(0, 2)) !== -1;
}

/*
* es-AR validation function
* Clave Única de Identificación Tributaria (CUIT/CUIL)
* Sourced from:
* - https://servicioscf.afip.gob.ar/publico/abc/ABCpaso2.aspx?id_nivel1=3036&id_nivel2=3040&p=Conceptos%20b%C3%A1sicos
* - https://es.wikipedia.org/wiki/Clave_%C3%9Anica_de_Identificaci%C3%B3n_Tributaria
*/

function esArCheck(tin) {
let accum = 0;
let digits = tin.split('');
let digit = parseInt(digits.pop(), 10);
for (let i = 0; i < digits.length; i++) {
accum += digits[9 - i] * (2 + (i % 6));
}
let verif = 11 - (accum % 11);
if (verif === 11) {
verif = 0;
} else if (verif === 10) {
verif = 9;
}
return digit === verif;
}

/*
* es-ES validation function
* (Documento Nacional de Identidad (DNI)
Expand Down Expand Up @@ -1137,6 +1161,7 @@ const taxIdFormat = {
'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-AR': /(20|23|24|27|30|33|34)[0-9]{8}[0-9]/,
'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,
Expand Down Expand Up @@ -1175,6 +1200,7 @@ const taxIdCheck = {
'en-CA': isCanadianSIN,
'en-IE': enIeCheck,
'en-US': enUsCheck,
'es-AR': esArCheck,
'es-ES': esEsCheck,
'et-EE': etEeCheck,
'fi-FI': fiFiCheck,
Expand Down
1 change: 1 addition & 0 deletions src/lib/isUUID.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const 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,
7: /^[0-9A-F]{8}-[0-9A-F]{4}-7[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,
};

Expand Down
Loading
Loading