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: release 2301 prep - v13.9.0 #2166

Closed
wants to merge 154 commits into from
Closed
Show file tree
Hide file tree
Changes from 141 commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
58cc918
feat: added support for Bengali language
May 27, 2021
74ea0fb
removed local changes
May 27, 2021
5e1c0cd
feat(isMobilePhone): add my-MM locale (#1813)
ferdousulhaque Nov 17, 2021
667b0bf
fix(docs): add missing options synthax on isISO8601 validator (#1860)
leonardovillela Nov 17, 2021
9c12b4c
fix(isMobilePhone): update de-DE regex to exclude landline numbers (#…
thomaschaaf Nov 17, 2021
f055c11
feat(isMACAddress): add EUI-64 validation (#1865)
WikiRik Nov 17, 2021
42ecd6c
Changes Made in Branch
rak810 Nov 17, 2021
9cfd06a
feat: (isMobilePhone) add Cyprus validation
ikerasiotis Jan 19, 2022
7c396cc
feat (isMobilePhone): add Nicaragua validator
ajGingrich Jan 20, 2022
23d94ae
add back trailing space to readme
ajGingrich Jan 20, 2022
c194bda
Add Iran phone number
ArashST79 Feb 3, 2022
72f5b25
Update isMobilePhone.js
arsalanfiroozi Feb 4, 2022
aa07a24
Update validators.js
arsalanfiroozi Feb 4, 2022
843240f
Update README.md
arsalanfiroozi Feb 4, 2022
fba9680
Added isMobilePhone valid regex for Afghanistan, Yemen and Western Sa…
Mustafiz04 Feb 5, 2022
ff4cdfe
docs: add a security policy (#1861)
tux-tn Feb 17, 2022
2fad8ab
feat(isLicensePlate): add support for Swedish license plates (#1665)
elmaxe Feb 17, 2022
4ee1655
feat(isTaxID): Canadian Social Insurance Number (SIN) validator (#1867)
boonya Feb 17, 2022
c1b21a9
chore(maintainers): update list of maintainers (#1887)
ezkemboi Feb 17, 2022
c605fe6
fix: option allow_numeric_tld option in isFQDN
BigOsvaap Mar 13, 2022
3d7fd6a
feat(isMobilePhone): Added regex for Bahamas - en-BS
savannahvaith Mar 15, 2022
3cf0f84
refactor: replace deprecated String.prototype.substr()
CommanderRoot Mar 20, 2022
a51103c
en-IN and all india locale support for isLicensePlate
NishantJS Mar 22, 2022
3d4d04a
Updated German license plate regex
bennetfabian Mar 25, 2022
290debb
Also removed old regex
bennetfabian Mar 25, 2022
924f3bc
Removed obsolete alternation in German regex
bennetfabian Mar 25, 2022
080f7df
Added more DE license plate tests
bennetfabian Mar 25, 2022
1bb491c
Fix fi-FI mobile phone number format to support 050xxxx numbers
rapaantti Mar 28, 2022
70b028e
fix phone numner validation for ka-GE locale
Apr 1, 2022
b415ade
update regexp
Apr 1, 2022
cf8dcea
feat(isBase32): Add option for Crockford's base 32 alternative (#1888)
BigOsvaap Apr 22, 2022
b039202
feat(isISO6391): add ISO 639-1 validator (#1892)
braaar Apr 22, 2022
495a175
feat(isMobilePhone): add Lesotho, en-LS locale (#1896)
DevilsAutumn Apr 22, 2022
4b8eac5
fix(isMobilePhone): update az-AZ (#1910)
seabeya Apr 22, 2022
066869c
fix(isDataURI): fix dataURI mediaType format (#1916)
temoffey Apr 22, 2022
cfcf911
chore: add code scan (#1859)
profnandaa Apr 22, 2022
9055591
Update isMobilePhone.js for pt-BR
jhcaiafa May 10, 2022
913d75c
Update validator.js - pt-BR test for isMobilePhone
jhcaiafa May 10, 2022
95345ae
fix(isLength) added process to subtract Presentation Sequences charac…
ikkyu-3 May 15, 2022
2e52efe
refactor(isIP): removed redundant check for IPv4 addresses
UnKnoWn-Consortium May 16, 2022
d9896ca
feat(isLuhnValid): Expose isLuhnValid independently from isCreditCard
ST-DDT May 22, 2022
4098467
test: add tests specifically for isLuhnValid
ST-DDT May 23, 2022
61ee147
feat(isMobilePhone): Added regex for Mongolia mn-MN
Jun 11, 2022
d88c7b6
fix(Honduras_enhancement): added the correct regex for phone numbers …
ademyan05 Jun 11, 2022
4758af0
Merge pull request #1 from rkuma552/feature/add-country-tophone
Jun 11, 2022
68ea9c4
Merge pull request #1 from ademyan05/fix/Honduras_enhancement
ademyan05 Jun 11, 2022
2a26c9f
feat(Jamaica-addition): added en-JM to isMobilePhone.js
ademyan05 Jun 13, 2022
7786bb3
feat(jamaica-addition): cleaned the branch
ademyan05 Jun 13, 2022
2280ff1
Revert "fix(Honduras_enhancement): added the correct regex for phone …
ademyan05 Jun 13, 2022
d50c860
"fix(Honduras_enhancement): added the correct regex for phone numbers…
ademyan05 Jun 13, 2022
61c9a1c
Update validators.js
Dev1lDragon Jun 16, 2022
bcac756
Update README.md
Dev1lDragon Jun 24, 2022
73098eb
feat(isMobilePhone): Added regex for Mongolia mn-MN (#1993)
rksp25 Jun 30, 2022
47443d1
fix: Modify pattern of pt-Br regex (#1951)
matheusnascgomes Jun 30, 2022
97d992c
fix(isPostalCode): update bosnian, BA locale (#1956)
zlayabekrija Jun 30, 2022
9a0bb35
fix(matches): prevent regex state from breaking following validations…
fedeci Jun 30, 2022
0175670
feat(isMagnetURI): support Bittorrent v2 (#1992)
Rhilip Jun 30, 2022
37cbd5c
fix(docs): missing SK locale isPostalCode (#1957)
tfilo Jun 30, 2022
5d2ff83
do not check if the host is valid if no host is specified
mortbauer Jul 2, 2022
6fb8bb5
feat(isMobilePhone): Added regex for Aruba nl-AW (#1985)
adida948 Jul 3, 2022
4767c21
feat(isMobilePhone): Added regex for Benin fr-BJ
Jul 4, 2022
2942078
Add Sinhala(si-LK) language support
Jul 5, 2022
12c82b9
Merge branch 'master' into feature/add-country-benin
rksp25 Jul 5, 2022
f219330
feat(isPassportNumber): add regex for mexico
samilieberman Jul 5, 2022
25c1504
feat(madagascar): regex added for madagascar mg-MG
Jul 13, 2022
4bf55e4
Merge pull request #2001 from ShivangiRai1310/feat/madagascar
rubiin Jul 17, 2022
d5f8015
Merge pull request #1998 from samilieberman/feat/mexico
rubiin Jul 17, 2022
9f89f3b
Merge pull request #1995 from mortbauer/fix/isURL-empty-host-with-query
rubiin Jul 17, 2022
fdbb1ee
Merge pull request #1996 from melkorCBA/master
rubiin Jul 17, 2022
c6ecf53
Merge pull request #1983 from ademyan05/master
rubiin Jul 17, 2022
2f26bac
Merge pull request #1942 from CommanderRoot/rm-deprecated-substr
rubiin Jul 17, 2022
c57ff39
Merge pull request #1974 from ST-DDT/expose/luhnCheck
rubiin Jul 17, 2022
8f04ca9
Merge pull request #1939 from BigOsvaap/fix-isFQDN-allow_numeric_tld-…
rubiin Jul 17, 2022
ceeb7b2
feat: added Papua New Guinea mobile number validation
kai2128 Jul 17, 2022
625603d
Merge branch 'master' into feature/add-country-benin
rksp25 Jul 17, 2022
ccf4170
Merge pull request #2002 from kai2128/master
rubiin Jul 18, 2022
8233ff1
Merge pull request #1946 from rapaantti/is-mobile-phone-finnish-numbers
rubiin Jul 18, 2022
49c3abe
Merge pull request #1967 from ikkyu-3/master
rubiin Jul 18, 2022
46118dc
Merge pull request #1944 from NishantJS/master
rubiin Jul 18, 2022
eaca48e
Merge pull request #1945 from bennetfabian/update/de-licenseplates
rubiin Jul 18, 2022
518a663
Merge pull request #1969 from UnKnoWn-Consortium/refactor-isip
rubiin Jul 18, 2022
4096915
Merge branch 'master' into feature/add-country-benin
rksp25 Jul 18, 2022
a17421a
Merge pull request #1997 from rksp25/feature/add-country-benin
rubiin Jul 18, 2022
7b8149b
feat(isMobilePhone): added Antigua and Barbuda mobile number validati…
jiaweilow Jul 19, 2022
ed3d8a4
Merge pull request #2004 from jiaweilow/master
rubiin Jul 19, 2022
356f055
Merge branch 'master' into patch-1
rubiin Jul 19, 2022
e483f6a
Merge pull request #1964 from jhcaiafa/patch-1
rubiin Jul 19, 2022
374a0b7
Merge branch 'master' into master
rubiin Jul 19, 2022
c8c247c
Merge pull request #1924 from arsalanfiroozi/master
rubiin Jul 19, 2022
678e55b
Merge pull request #1952 from avkvak/ka-ge-phone-regex-fix
rubiin Jul 19, 2022
222cacc
Merge branch 'master' into master
rubiin Jul 19, 2022
c193fe5
Merge pull request #1922 from ArashST79/master
rubiin Jul 19, 2022
afdbd68
Merge branch 'master' into feature/all-country-regex
rubiin Jul 19, 2022
89949e7
Merge pull request #1925 from Mustafiz04/feature/all-country-regex
rubiin Jul 19, 2022
a14f4de
Merge branch 'master' into feat/1761-mobile-phone-validation
rubiin Jul 19, 2022
aead076
Merge pull request #1940 from savannahvaith/feat/1761-mobile-phone-va…
rubiin Jul 19, 2022
f2d7e04
Merge branch 'master' into nicaragua-phone
rubiin Jul 19, 2022
edce476
Merge pull request #1909 from ajGingrich/nicaragua-phone
rubiin Jul 19, 2022
da1a936
Merge branch 'master' into master
rubiin Jul 19, 2022
3873ebf
Merge pull request #1897 from ikerasiotis/master
rubiin Jul 19, 2022
c7c0760
Merge branch 'master' into master
rubiin Jul 19, 2022
35b5ffb
Merge pull request #1678 from rak810/master
rubiin Jul 19, 2022
7832d4a
Merge pull request #1989 from Dev1lDragon/patch-1
rubiin Jul 19, 2022
35fc280
Merge branch 'master' into feat/Jamaica-addition
rubiin Jul 19, 2022
450a2c0
Merge pull request #1986 from ademyan05/feat/Jamaica-addition
rubiin Jul 19, 2022
1bb14e8
feat(isMobilePhone): added Anguilla, en-AI, locale (#2007)
elaine1129 Jul 23, 2022
2d70100
Fix broken Validators table at README.md
marcelozarate Jul 27, 2022
86a07ba
Merge pull request #2010 from marcelozarate/patch-1
rubiin Aug 6, 2022
e143430
Remove 'Changes made' from README
WikiRik Aug 10, 2022
edf445a
feat(isPassportNumber): add passport number of thailand, TH (#1814)
TonPC64 Oct 17, 2022
c1d1b48
feat(isEmail): add whitelist host to isEmail validation (#1920)
poor-cooder Oct 17, 2022
ee33432
feat(isCreditCard): enhancements (#2008)
brianwhaley Oct 17, 2022
2c785a5
feat(isMobilePhone): added Saint Kitts and Nevis locale, en-KN (#2011)
Eelyneee Oct 17, 2022
d698f4f
feat(isAlpha, isAlphanumeric): add japanese locale, ja-JP (#2014)
starcharles Oct 17, 2022
7b47f53
feat(isAlpha, isAlphanumeric): add ko-KR locale (#1965)
Dongkyuuuu Oct 17, 2022
531dc7f
Merge pull request #2024 from WikiRik/patch-1
rubiin Oct 19, 2022
93667bd
chore(CodeQL): update deprecated v1 to v2 (#2150)
pano9000 Jan 19, 2023
c19777a
feat(isIdentityCard): add hk-HK locale (#2142)
songyuew Jan 20, 2023
41c7a16
feat(isMobilePhone): add south sudan locale, en-SS (#2084)
cheboi Jan 22, 2023
ee81073
fix(isStrongPassword): add £ as symbol (#2148)
sandmule Jan 22, 2023
cca678a
fix(isMobilePhone): added extra prefix for ar-KW locale (#2138)
Yazan-KE Jan 22, 2023
f394da0
test(validators): remove duplicated test (#2137)
pano9000 Jan 22, 2023
394eebf
fix(isPostalCode): fix overly permissive IR regexp (#2136)
pano9000 Jan 22, 2023
dcb6cb6
refactor(isBtcAddress): get rid of unnecessary if statement and comme…
pano9000 Jan 22, 2023
d8f3a24
fix(isMobilePhone): re-add es-HN fix from #1983 (#2129)
WikiRik Jan 22, 2023
a571b3e
fix(isDataURI): fix MIME types with underscores not getting matched …
pano9000 Jan 22, 2023
44224d7
fix(isMobilePhone): fix el-GR validation - add missing ranges and cor…
pano9000 Jan 22, 2023
8e004e0
added isTime validator (#1479)
francoatmega Jan 22, 2023
7bef722
fix(isPostalCode): fix overly permissive BY regexp (#2134)
pano9000 Jan 22, 2023
35b1fc1
refactor: change test files to prepare for #1874 (#2091)
WikiRik Jan 28, 2023
f97e8d4
fix(docs): remove duplicated "New Features" section in CHANGELOG (#2118)
pano9000 Jan 28, 2023
d25559b
fix(isMobilePhone): fix wrong dv-MV mobile phone matching (issue #210…
pano9000 Jan 29, 2023
0586d23
docs: Improve consistency and fix errors in README.md (#2107)
pano9000 Jan 29, 2023
8deae54
fix(isLicensePlate): remove duplicate char from character class (#2085)
pedroprado010 Jan 29, 2023
c332e5c
fix(isMimeType): Fix MIME Types with underscores not getting matched …
pano9000 Jan 29, 2023
d61322c
fix(isMobilePhone): fix 'ro-RO' matching invalid numbers (#2156)
pano9000 Jan 29, 2023
f9d49fc
fix(isMobilePhone): fix 'ms-MY' regexp (#2155)
pano9000 Jan 29, 2023
c81df18
fix(isMobilePhone): Fix en-BM matching invalid numbers due to missing…
pano9000 Jan 29, 2023
b2a999d
fix(isRgbColor): fix validation of rgb(a) ColorPercentage strings (#2…
pano9000 Jan 29, 2023
753c29d
feat(isAfter): allow usage of options object (#2075)
WikiRik Jan 29, 2023
6dba289
feat(isISBN): allow usage of options object (#2157)
WikiRik Jan 30, 2023
8604748
feat(isPassportNumber): new locales JM,KZ,LI,NZ
profnandaa Jan 31, 2023
427b035
feat(isLicensePlate): add hu-HU locale (#2165)
profnandaa Jan 31, 2023
bde420b
feat(isMobilePhone): add ro-MD locale (#2167)
profnandaa Jan 31, 2023
5bb8c91
feat:(isMobilePhone): add fr-CD, DR Congo locale (#2168)
profnandaa Jan 31, 2023
a310168
feat(isLicensePlate): add es-AR locale (#2169)
profnandaa Jan 31, 2023
b489355
fix(isEmail): fixed `isFQDN`'s `ignore_max_length` check (#2170)
profnandaa Feb 1, 2023
31a74d5
feat(isPassportNumber): add PH and PK locales (#2172)
profnandaa Feb 2, 2023
58f4b13
feat(isPassportNumber): add regex for AZ locale (#2173)
profnandaa Feb 2, 2023
c6f2196
fix(isFloat): fix comma passing as float (#2174)
profnandaa Feb 2, 2023
91c8bd9
Merge pull request #2164 from validatorjs/mcfix/combined-prs
profnandaa Feb 2, 2023
a8e0005
fix(isBIC): add `XK` to accepted BIC country codes (#2046)
import-brain Feb 2, 2023
d423220
fix: few pre-release fixes
profnandaa Feb 2, 2023
54d330c
13.9.0
profnandaa Feb 2, 2023
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
70 changes: 70 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '38 10 * * 4'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ yarn.lock
/index.js
validator.js
validator.min.js

4 changes: 0 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@

- [#1706](https://github.com/validatorjs/validator.js/pull/1706) `isISO4217`, currency code validator @jpaya17

### New Features

- [#1706](https://github.com/validatorjs/validator.js/pull/1706) `isISO4217`, currency code validator @jpaya17

### Fixes and Enhancements

- [#1647](https://github.com/validatorjs/validator.js/pull/1647) `isFQDN`: add `allow_wildcard` option @fasenderos
Expand Down
147 changes: 89 additions & 58 deletions README.md

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Security Policy

## Supported Versions

In the case of a confirmed security issue, only the current version of validator is guaranteed to be patched.

## Reporting a Vulnerability

**Please don't disclose security-related issues publicly.**

If you discover a vulnerability within validator, please use [huntr.dev disclosure form](https://huntr.dev/bounties/disclose/?target=https://github.com/validatorjs/validator.js). We will try to validate and respond to reports in a reasonable time. if the issue is confirmed, we will create a security advisory and a patch as soon as possible.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"build:node": "babel src -d .",
"build": "run-p build:*",
"pretest": "npm run build && npm run lint",
"test": "nyc --reporter=cobertura --reporter=text-summary mocha --require @babel/register --reporter dot"
"test": "nyc --reporter=cobertura --reporter=text-summary mocha --require @babel/register --reporter dot --recursive"
},
"engines": {
"node": ">= 0.10"
Expand Down
6 changes: 6 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import isIP from './lib/isIP';
import isIPRange from './lib/isIPRange';
import isFQDN from './lib/isFQDN';
import isDate from './lib/isDate';
import isTime from './lib/isTime';

import isBoolean from './lib/isBoolean';
import isLocale from './lib/isLocale';
Expand Down Expand Up @@ -69,6 +70,7 @@ import isBefore from './lib/isBefore';

import isIn from './lib/isIn';

import isLuhnValid from './lib/isLuhnValid';
import isCreditCard from './lib/isCreditCard';
import isIdentityCard from './lib/isIdentityCard';

Expand All @@ -86,6 +88,7 @@ import isCurrency from './lib/isCurrency';

import isBtcAddress from './lib/isBtcAddress';

import isISO6391 from './lib/isISO6391';
import isISO8601 from './lib/isISO8601';
import isRFC3339 from './lib/isRFC3339';
import isISO31661Alpha2 from './lib/isISO31661Alpha2';
Expand Down Expand Up @@ -182,6 +185,7 @@ const validator = {
isAfter,
isBefore,
isIn,
isLuhnValid,
isCreditCard,
isIdentityCard,
isEAN,
Expand All @@ -195,6 +199,7 @@ const validator = {
isEthereumAddress,
isCurrency,
isBtcAddress,
isISO6391,
isISO8601,
isRFC3339,
isISO31661Alpha2,
Expand Down Expand Up @@ -222,6 +227,7 @@ const validator = {
isStrongPassword,
isTaxID,
isDate,
isTime,
isLicensePlate,
isVAT,
ibanLocales,
Expand Down
29 changes: 21 additions & 8 deletions src/lib/alpha.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const alpha = {
'fi-FI': /^[A-ZÅÄÖ]+$/i,
'fr-FR': /^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,
'it-IT': /^[A-ZÀÉÈÌÎÓÒÙ]+$/i,
'ja-JP': /^[ぁ-んァ-ヶヲ-゚一-龠ー・。、]+$/i,
'nb-NO': /^[A-ZÆØÅ]+$/i,
'nl-NL': /^[A-ZÁÉËÏÓÖÜÚ]+$/i,
'nn-NO': /^[A-ZÆØÅ]+$/i,
Expand All @@ -27,11 +28,14 @@ export const alpha = {
'tr-TR': /^[A-ZÇĞİıÖŞÜ]+$/i,
'uk-UA': /^[А-ЩЬЮЯЄIЇҐі]+$/i,
'vi-VN': /^[A-ZÀÁẠẢÃÂẦẤẬẨẪĂẰẮẶẲẴĐÈÉẸẺẼÊỀẾỆỂỄÌÍỊỈĨÒÓỌỎÕÔỒỐỘỔỖƠỜỚỢỞỠÙÚỤỦŨƯỪỨỰỬỮỲÝỴỶỸ]+$/i,
'ko-KR': /^[ㄱ-ㅎㅏ-ㅣ가-힣]*$/,
'ku-IQ': /^[ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
he: /^[א-ת]+$/,
fa: /^['آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی']+$/i,
bn: /^['ঀঁংঃঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহ়ঽািীুূৃৄেৈোৌ্ৎৗড়ঢ়য়ৠৡৢৣৰৱ৲৳৴৵৶৷৸৹৺৻']+$/,
'hi-IN': /^[\u0900-\u0961]+[\u0972-\u097F]*$/i,
'si-LK': /^[\u0D80-\u0DFF]+$/,
};

export const alphanumeric = {
Expand All @@ -46,6 +50,7 @@ export const alphanumeric = {
'fi-FI': /^[0-9A-ZÅÄÖ]+$/i,
'fr-FR': /^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,
'it-IT': /^[0-9A-ZÀÉÈÌÎÓÒÙ]+$/i,
'ja-JP': /^[0-90-9ぁ-んァ-ヶヲ-゚一-龠ー・。、]+$/i,
'hu-HU': /^[0-9A-ZÁÉÍÓÖŐÚÜŰ]+$/i,
'nb-NO': /^[0-9A-ZÆØÅ]+$/i,
'nl-NL': /^[0-9A-ZÁÉËÏÓÖÜÚ]+$/i,
Expand All @@ -61,12 +66,15 @@ export const alphanumeric = {
'th-TH': /^[ก-๙\s]+$/i,
'tr-TR': /^[0-9A-ZÇĞİıÖŞÜ]+$/i,
'uk-UA': /^[0-9А-ЩЬЮЯЄIЇҐі]+$/i,
'ko-KR': /^[0-9ㄱ-ㅎㅏ-ㅣ가-힣]*$/,
'ku-IQ': /^[٠١٢٣٤٥٦٧٨٩0-9ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,
'vi-VN': /^[0-9A-ZÀÁẠẢÃÂẦẤẬẨẪĂẰẮẶẲẴĐÈÉẸẺẼÊỀẾỆỂỄÌÍỊỈĨÒÓỌỎÕÔỒỐỘỔỖƠỜỚỢỞỠÙÚỤỦŨƯỪỨỰỬỮỲÝỴỶỸ]+$/i,
ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/,
he: /^[0-9א-ת]+$/,
fa: /^['0-9آاءأؤئبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهةی۱۲۳۴۵۶۷۸۹۰']+$/i,
bn: /^['ঀঁংঃঅআইঈউঊঋঌএঐওঔকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহ়ঽািীুূৃৄেৈোৌ্ৎৗড়ঢ়য়ৠৡৢৣ০১২৩৪৫৬৭৮৯ৰৱ৲৳৴৵৶৷৸৹৺৻']+$/,
'hi-IN': /^[\u0900-\u0963]+[\u0966-\u097F]*$/i,
'si-LK': /^[0-9\u0D80-\u0DFF]+$/,
};

export const decimal = {
Expand All @@ -85,10 +93,8 @@ for (let locale, i = 0; i < englishLocales.length; i++) {
}

// Source: http://www.localeplanet.com/java/
export const arabicLocales = [
'AE', 'BH', 'DZ', 'EG', 'IQ', 'JO', 'KW', 'LB', 'LY',
'MA', 'QM', 'QA', 'SA', 'SD', 'SY', 'TN', 'YE',
];
export const arabicLocales = ['AE', 'BH', 'DZ', 'EG', 'IQ', 'JO', 'KW', 'LB', 'LY',
'MA', 'QM', 'QA', 'SA', 'SD', 'SY', 'TN', 'YE'];

for (let locale, i = 0; i < arabicLocales.length; i++) {
locale = `ar-${arabicLocales[i]}`;
Expand All @@ -97,22 +103,29 @@ for (let locale, i = 0; i < arabicLocales.length; i++) {
decimal[locale] = decimal.ar;
}

export const farsiLocales = [
'IR', 'AF',
];
export const farsiLocales = ['IR', 'AF'];

for (let locale, i = 0; i < farsiLocales.length; i++) {
locale = `fa-${farsiLocales[i]}`;
alphanumeric[locale] = alphanumeric.fa;
decimal[locale] = decimal.ar;
}

export const bengaliLocales = ['BD', 'IN'];

for (let locale, i = 0; i < bengaliLocales.length; i++) {
locale = `bn-${bengaliLocales[i]}`;
alpha[locale] = alpha.bn;
alphanumeric[locale] = alphanumeric.bn;
decimal[locale] = decimal['en-US'];
}

// 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',
'id-ID', 'it-IT', 'ku-IQ', 'hi-IN', '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',
'ru-RU', 'si-LK', 'sl-SI', 'sr-RS@latin', 'sr-RS', 'sv-SE', 'tr-TR', 'uk-UA', 'vi-VN',
];

for (let i = 0; i < dotDecimal.length; i++) {
Expand Down
12 changes: 7 additions & 5 deletions src/lib/isAfter.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import assertString from './util/assertString';
import toDate from './toDate';

export default function isAfter(str, date = String(new Date())) {
assertString(str);
const comparison = toDate(date);
const original = toDate(str);
export default function isAfter(date, options) {
// For backwards compatibility:
// isAfter(str [, date]), i.e. `options` could be used as argument for the legacy `date`
const comparisonDate = options?.comparisonDate || options || Date().toString();

const comparison = toDate(comparisonDate);
const original = toDate(date);
return !!(original && comparison && original > comparison);
}
14 changes: 13 additions & 1 deletion src/lib/isBase32.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
import assertString from './util/assertString';
import merge from './util/merge';

const base32 = /^[A-Z2-7]+=*$/;
const crockfordBase32 = /^[A-HJKMNP-TV-Z0-9]+$/;

export default function isBase32(str) {
const defaultBase32Options = {
crockford: false,
};

export default function isBase32(str, options) {
assertString(str);
options = merge(options, defaultBase32Options);

if (options.crockford) {
return crockfordBase32.test(str);
}

const len = str.length;
if (len % 8 === 0 && base32.test(str)) {
return true;
Expand Down
7 changes: 1 addition & 6 deletions src/lib/isBtcAddress.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import assertString from './util/assertString';

// supports Bech32 addresses
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);
// check for bech32
if (str.startsWith('bc1')) {
return bech32.test(str);
}
return base58.test(str);
return bech32.test(str) || base58.test(str);
}
51 changes: 26 additions & 25 deletions src/lib/isCreditCard.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
import assertString from './util/assertString';
import isLuhnValid from './isLuhnValid';

const cards = {
amex: /^3[47][0-9]{13}$/,
dinersclub: /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/,
discover: /^6(?:011|5[0-9][0-9])[0-9]{12,15}$/,
jcb: /^(?:2131|1800|35\d{3})\d{11}$/,
mastercard: /^5[1-5][0-9]{2}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$/, // /^[25][1-7][0-9]{14}$/;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this alternative RegExp is in the comments, but maybe we can look at that in #2117

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like the comment is a more "generalized" version of the final regexp used here.
I would tend to vote to remove the comment, it only causes confusion, but again, this can be part of my refactor #2117

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think removal is the best and also best to do in the refactor

unionpay: /^(6[27][0-9]{14}|^(81[0-9]{14,17}))$/,
visa: /^(?:4[0-9]{12})(?:[0-9]{3,6})?$/,
};
/* eslint-disable max-len */
const 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}|^(81[0-9]{14,17}))$/;
const allCards = /^(?: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}|^(81[0-9]{14,17}))$/;
/* eslint-enable max-len */

export default function isCreditCard(str) {
assertString(str);
const sanitized = str.replace(/[- ]+/g, '');
if (!creditCard.test(sanitized)) {
return false;
}
let sum = 0;
let digit;
let tmpNum;
let shouldDouble;
for (let 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;
export default function isCreditCard(card, options = {}) {
assertString(card);
const { provider } = options;
const sanitized = card.replace(/[- ]+/g, '');
if (provider && provider.toLowerCase() in cards) {
// specific provider in the list
if (!(cards[provider.toLowerCase()].test(sanitized))) {
return false;
}
shouldDouble = !shouldDouble;
} else if (provider && !(provider.toLowerCase() in cards)) {
/* specific provider not in the list */
throw new Error(`${provider} is not a valid credit card provider.`);
} else if (!(allCards.test(sanitized))) {
// no specific provider
return false;
}
return !!((sum % 10) === 0 ? sanitized : false);
return isLuhnValid(card);
}
6 changes: 3 additions & 3 deletions src/lib/isDataURI.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assertString from './util/assertString';

const validMediaType = /^[a-z]+\/[a-z0-9\-\+]+$/i;
const validMediaType = /^[a-z]+\/[a-z0-9\-\+\._]+$/i;

const validAttribute = /^[a-z\-]+=[a-z0-9\-]+$/i;

Expand All @@ -14,10 +14,10 @@ export default function isDataURI(str) {
}
const attributes = data.shift().trim().split(';');
const schemeAndMediaType = attributes.shift();
if (schemeAndMediaType.substr(0, 5) !== 'data:') {
if (schemeAndMediaType.slice(0, 5) !== 'data:') {
return false;
}
const mediaType = schemeAndMediaType.substr(5);
const mediaType = schemeAndMediaType.slice(5);
if (mediaType !== '' && !validMediaType.test(mediaType)) {
return false;
}
Expand Down
Loading