Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
c8f6460
test: split isEmail validator tests
Apr 15, 2026
7c3d232
test: split isURL validator tests
Apr 15, 2026
3b1667f
test: split isMACAddress validator tests
Apr 15, 2026
c06f58e
test: split isIPRange validator tests
Apr 15, 2026
b2999f6
test: split isAlpha validator tests
Apr 15, 2026
5824d5c
test: split isAlphanumeric validator tests
Apr 15, 2026
0a14840
test: split isNumeric validator tests
Apr 15, 2026
86dfd19
test: split isPort validator tests
Apr 15, 2026
8d4e04c
test: split isPassportNumber validator tests
Apr 15, 2026
d2916b0
test: split isDecimal validator tests
Apr 15, 2026
9a975eb
test: split isLowercase validator tests
Apr 15, 2026
e2f1f8c
test: split isIMEI validator tests
Apr 15, 2026
d6795d8
test: split isUppercase validator tests
Apr 15, 2026
bf82b58
test: split isInt validator tests
Apr 15, 2026
bdbebf2
test: split isFloat validator tests
Apr 15, 2026
0a88997
test: split isHexadecimal validator tests
Apr 15, 2026
7269f83
test: split isOctal validator tests
Apr 15, 2026
efc338d
test: split isHexColor validator tests
Apr 15, 2026
7ea79a8
test: split isHSL validator tests
Apr 15, 2026
e57b5c1
test: split isRgbColor validator tests
Apr 15, 2026
73f1cbe
test: split isISRC validator tests
Apr 15, 2026
0c2e05f
test: split isMD5 validator tests
Apr 15, 2026
2e5c3f8
test: split isHash validator tests
Apr 15, 2026
a54973f
test: split isJWT validator tests
Apr 15, 2026
0803680
test: split isEmpty validator tests
Apr 15, 2026
d2ec7f3
test: split equals validator tests
Apr 15, 2026
f90c41d
test: split contains validator tests
Apr 15, 2026
6711e41
test: split matches validator tests
Apr 15, 2026
fb3961f
test: split isLocale validator tests
Apr 15, 2026
f39c194
test: split isByteLength validator tests
Apr 15, 2026
c6ce929
test: split isULID validator tests
Apr 15, 2026
efadf61
test: split isUUID validator tests
Apr 15, 2026
387fa2c
test: split isIn validator tests
Apr 15, 2026
a559c74
test: split isAbaRouting validator tests
Apr 15, 2026
a79b3e2
test: split isIBAN validator tests
Apr 15, 2026
688425f
test: split isBIC validator tests
Apr 15, 2026
acd27b3
test: split isDivisibleBy validator tests
Apr 15, 2026
5e79739
test: split isLuhnNumber validator tests
Apr 15, 2026
5e72e73
test: split isCreditCard validator tests
Apr 15, 2026
0118135
test: split isIdentityCard validator tests
Apr 15, 2026
b880280
test: split isISIN validator tests
Apr 15, 2026
0fba838
test: split isEAN validator tests
Apr 15, 2026
4dd5828
test: split isISSN validator tests
Apr 15, 2026
557b533
test: split isJSON validator tests
Apr 15, 2026
67c352d
test: split isMultibyte validator tests
Apr 15, 2026
abba811
test: split isAscii validator tests
Apr 15, 2026
08e9266
test: split isFullWidth validator tests
Apr 15, 2026
03ea269
test: split isHalfWidth validator tests
Apr 15, 2026
47cee40
test: split isVariableWidth validator tests
Apr 15, 2026
5071711
test: split isSurrogatePair validator tests
Apr 15, 2026
3c30620
test: split isSemVer validator tests
Apr 15, 2026
569ece1
test: split isBase32 validator tests
Apr 15, 2026
4bb4035
test: split isBase58 validator tests
Apr 15, 2026
2e0a35e
test: split isMongoId validator tests
Apr 15, 2026
66f54a0
test: split isMobilePhone validator tests
Apr 15, 2026
73705e1
test: split isCurrency validator tests
Apr 15, 2026
8b9d135
test: split isEthereumAddress validator tests
Apr 15, 2026
0232f9c
test: split isBtcAddress validator tests
Apr 15, 2026
469bf57
test: split isBoolean validator tests
Apr 15, 2026
698ed5e
test: split isISO6391 validator tests
Apr 15, 2026
ff63944
test: split isISO8601 validator tests
Apr 15, 2026
a0112db
test: split isISO15924 validator tests
Apr 15, 2026
c140e19
test: split isRFC3339 validator tests
Apr 15, 2026
d0e0900
test: split isFQDN validator tests
Apr 15, 2026
1f74ec4
test: split isISO31661Numeric validator tests
Apr 15, 2026
8a29ed7
test: split isISO4217 validator tests
Apr 15, 2026
c57bb93
test: split isWhitelisted validator tests
Apr 15, 2026
10b45a0
test: split isDataURI validator tests
Apr 15, 2026
f235a01
test: split isMagnetURI validator tests
Apr 15, 2026
ccafa01
test: split isLatLong validator tests
Apr 15, 2026
52917d1
test: split isPostalCode validator tests
Apr 15, 2026
19f0c19
test: split isMimeType validator tests
Apr 15, 2026
31e0c19
test: split isISO6346 validator tests
Apr 15, 2026
494c944
test: split isFreightContainerID validator tests
Apr 15, 2026
74249e3
test: split isTaxID validator tests
Apr 15, 2026
b3f6406
test: split isSlug validator tests
Apr 15, 2026
e028ab8
test: split isStrongPassword validator tests
Apr 15, 2026
c8e5ec3
test: split isDate validator tests
Apr 15, 2026
2e01359
test: split isTime validator tests
Apr 15, 2026
c2259fb
test: split isLicensePlate validator tests
Apr 15, 2026
3da7252
test: split isVAT validator tests
Apr 15, 2026
cdf0c52
test: split isMailtoURI validator tests
Apr 15, 2026
1a49189
test: split toBoolean sanitizer tests
Apr 15, 2026
70f6cc8
test: split trim sanitizer tests
Apr 15, 2026
2ab2fc8
test: split ltrim sanitizer tests
Apr 15, 2026
5f69229
test: split rtrim sanitizer tests
Apr 15, 2026
2af25c6
test: split toInt sanitizer tests
Apr 15, 2026
9e16a7b
test: split toFloat sanitizer tests
Apr 15, 2026
e24d358
test: split escape sanitizer tests
Apr 15, 2026
971fc82
test: split unescape sanitizer tests
Apr 15, 2026
accfd9f
test: split stripLow sanitizer tests
Apr 15, 2026
5ccbe0f
test: split whitelist sanitizer tests
Apr 15, 2026
9c7caa0
test: split blacklist sanitizer tests
Apr 15, 2026
e0e0e7c
test: split isStrongPassword sanitizer tests
Apr 15, 2026
4bfcb36
test: split normalizeEmail sanitizer tests
Apr 15, 2026
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
16 changes: 16 additions & 0 deletions test/sanitizers/blacklist.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import test from '../testFunctions';

describe('blacklist', () => {
it('should sanitize a string based on a blacklist', () => {
test({
sanitizer: 'blacklist',
args: ['abc'],
expect: {
abcdef: 'def',
aaaaaaaaaabbbbbbbbbb: '',
a1b2c3: '123',
' ': ' ',
},
});
});
});
22 changes: 22 additions & 0 deletions test/sanitizers/escape.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import test from '../testFunctions';

describe('escape', () => {
it('should escape HTML', () => {
test({
sanitizer: 'escape',
expect: {
'<script> alert("xss&fun"); </script>':
'&lt;script&gt; alert(&quot;xss&amp;fun&quot;); &lt;&#x2F;script&gt;',

"<script> alert('xss&fun'); </script>":
'&lt;script&gt; alert(&#x27;xss&amp;fun&#x27;); &lt;&#x2F;script&gt;',

'Backtick: `':
'Backtick: &#96;',

'Backslash: \\':
'Backslash: &#x5C;',
},
});
});
});
39 changes: 39 additions & 0 deletions test/sanitizers/isStrongPassword.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import test from '../testFunctions';

describe('isStrongPassword', () => {
it('should score passwords', () => {
test({
sanitizer: 'isStrongPassword',
args: [{
returnScore: true,
pointsPerUnique: 1,
pointsPerRepeat: 0.5,
pointsForContainingLower: 10,
pointsForContainingUpper: 10,
pointsForContainingNumber: 10,
pointsForContainingSymbol: 10,
}],
expect: {
abc: 13,
abcc: 13.5,
aBc: 23,
'Abc123!': 47,
'!@#$%^&*()': 20,
},
});
});

it('should score passwords with default options', () => {
test({
sanitizer: 'isStrongPassword',
expect: {
abc: false,
abcc: false,
aBc: false,
'Abc123!': false,
'!@#$%^&*()': false,
'abc123!@f#rA': true,
},
});
});
});
27 changes: 27 additions & 0 deletions test/sanitizers/ltrim.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import test from '../testFunctions';

describe('ltrim', () => {
it('should trim whitespace', () => {
test({
sanitizer: 'ltrim',
expect: {
' \r\n\tfoo \r\n\t ': 'foo \r\n\t ',
' \t \n': '',
},
});
});

it('should trim custom characters', () => {
test({
sanitizer: 'ltrim',
args: ['01'],
expect: { '010100201000': '201000' },
});

test({
sanitizer: 'ltrim',
args: ['\\S'],
expect: { '\\S01010020100001': '01010020100001' },
});
});
});
Loading
Loading