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

Multiple fixes related to alpha, tests and build #1528

Merged
merged 10 commits into from
Nov 29, 2020
Merged
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ package-lock.json
yarn.lock
/es
/lib
validator.js
validator.min.js
index.js
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
sudo: false
language: node_js
node_js:
- stable
Expand Down
12 changes: 6 additions & 6 deletions README.md

Large diffs are not rendered by default.

296 changes: 0 additions & 296 deletions index.js

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"build:es": "babel src -d es --env-name=es",
"build:node": "babel src -d .",
"build": "npm run build:browser && npm run build:node && npm run build:es",
"pretest": "npm run lint && npm run build",
"pretest": "npm run build && npm run lint",
Copy link
Member

Choose a reason for hiding this comment

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

I think this is one of the things making my previous builds to fail, I'll retry the PR I'd reverted.

Copy link
Member Author

Choose a reason for hiding this comment

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

Exactly

"test": "nyc mocha --require @babel/register --reporter dot",
"test:ci": "nyc report --reporter=text-lcov"
},
Expand Down
17 changes: 9 additions & 8 deletions src/lib/alpha.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export const alphanumeric = {
export const decimal = {
'en-US': '.',
ar: '٫',
fa: '٫',
};


Expand Down Expand Up @@ -100,17 +99,16 @@ export const farsiLocales = [

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

// 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-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',
'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 (let i = 0; i < dotDecimal.length; i++) {
Expand All @@ -121,8 +119,8 @@ for (let i = 0; i < commaDecimal.length; i++) {
decimal[commaDecimal[i]] = ',';
}

// see #1455
alpha['fa-IR'] = alpha['fa-IR'];
alpha['fr-CA'] = alpha['fr-FR'];
alphanumeric['fr-CA'] = alphanumeric['fr-FR'];

alpha['pt-BR'] = alpha['pt-PT'];
alphanumeric['pt-BR'] = alphanumeric['pt-PT'];
Expand All @@ -132,3 +130,6 @@ decimal['pt-BR'] = decimal['pt-PT'];
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;
1 change: 1 addition & 0 deletions src/lib/isMobilePhone.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ const phones = {

// 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'];
Expand Down
14 changes: 14 additions & 0 deletions test/sanitizers.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,20 @@ describe('Sanitizers', () => {
});
});

it('should score passwords with default options', () => {
test({
sanitizer: 'isStrongPassword',
expect: {
abc: false,
abcc: false,
aBc: false,
'Abc123!': false,
'!@#$%^&*()': false,
'abc123!@f#rA': true,
},
});
});

it('should normalize an email based on domain', () => {
test({
sanitizer: 'normalizeEmail',
Expand Down
Loading