-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
250 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,5 @@ language: node_js | |
node_js: | ||
- stable | ||
- 8 | ||
- 6 | ||
notifications: | ||
email: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
import assertString from './util/assertString'; | ||
|
||
const numeric = /^[+-]?([0-9]*[.])?[0-9]+$/; | ||
const numericNoSymbols = /^[0-9]+$/; | ||
|
||
export default function isNumeric(str) { | ||
export default function isNumeric(str, options) { | ||
assertString(str); | ||
if (options && options.no_symbols) { | ||
return numericNoSymbols.test(str); | ||
} | ||
return numeric.test(str); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,8 @@ describe('Validators', () => { | |
'[email protected]', | ||
'[email protected]', | ||
'test123+invalid! [email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
], | ||
}); | ||
}); | ||
|
@@ -228,6 +230,52 @@ describe('Validators', () => { | |
}); | ||
}); | ||
|
||
it('should validate email addresses with allowed IPs', () => { | ||
test({ | ||
validator: 'isEmail', | ||
args: [{ allow_ip_domain: true }], | ||
valid: [ | ||
'email@[123.123.123.123]', | ||
'[email protected]', | ||
], | ||
invalid: [ | ||
'invalidemail@', | ||
'invalid.com', | ||
'@invalid.com', | ||
'[email protected].', | ||
'somename@gmail.com', | ||
'[email protected].', | ||
'[email protected]', | ||
'gmailgmailgmailgmailgmail@gmail.com', | ||
`${repeat('a', 64)}@${repeat('a', 251)}.com`, | ||
`${repeat('a', 65)}@${repeat('a', 250)}.com`, | ||
`${repeat('a', 64)}@${repeat('a', 64)}.com`, | ||
`${repeat('a', 31)}@gmail.com`, | ||
'[email protected] m', | ||
'[email protected] m', | ||
'[email protected] m', | ||
'[email protected] m', | ||
'[email protected] m', | ||
'[email protected] m', | ||
'[email protected] m', | ||
'[email protected] m', | ||
'[email protected] m', | ||
'[email protected] m', | ||
'[email protected] m', | ||
'[email protected] m', | ||
'[email protected] m', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'test123+invalid! [email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
], | ||
}); | ||
}); | ||
|
||
it('should validate URLs', () => { | ||
test({ | ||
|
@@ -1530,8 +1578,34 @@ describe('Validators', () => { | |
'-0', | ||
'+123', | ||
'123.123', | ||
'+000000', | ||
], | ||
invalid: [ | ||
' ', | ||
'', | ||
'.', | ||
], | ||
}); | ||
}); | ||
|
||
it('should validate numeric strings without symbols', () => { | ||
test({ | ||
validator: 'isNumeric', | ||
args: [{ | ||
no_symbols: true, | ||
}], | ||
valid: [ | ||
'123', | ||
'00123', | ||
'0', | ||
], | ||
invalid: [ | ||
'-0', | ||
'+000000', | ||
'', | ||
'+123', | ||
'123.123', | ||
'-00123', | ||
' ', | ||
'.', | ||
], | ||
|
@@ -3289,6 +3363,22 @@ describe('Validators', () => { | |
'12125559999', | ||
], | ||
}, | ||
{ | ||
locale: 'bn-BD', | ||
valid: [ | ||
'+8801794626846', | ||
'01199098893', | ||
'8801671163269', | ||
'01717112029', | ||
], | ||
invalid: [ | ||
'', | ||
'0174626346', | ||
'017943563469', | ||
'18001234567', | ||
'01494676946', | ||
], | ||
}, | ||
{ | ||
locale: 'cs-CZ', | ||
valid: [ | ||
|
@@ -3597,34 +3687,33 @@ describe('Validators', () => { | |
'19876543210', | ||
'8005552222', | ||
'+15673628910', | ||
'+1(567)3628910', | ||
'+1(567)362-8910', | ||
'+1(567) 362-8910', | ||
'1(567)362-8910', | ||
'1(567)362 8910', | ||
'223-456-7890', | ||
], | ||
invalid: [ | ||
'564785', | ||
'0123456789', | ||
'1437439210', | ||
'8009112340', | ||
'+10345672645', | ||
'11435213543', | ||
'2436119753', | ||
'16532116190', | ||
'1(067)362-8910', | ||
'1(167)362-8910', | ||
'+2(267)362-8910', | ||
], | ||
}, | ||
{ | ||
locale: 'en-CA', | ||
valid: [ | ||
'19876543210', | ||
'8005552222', | ||
'+15673628910', | ||
], | ||
valid: ['19876543210', '8005552222', '+15673628910'], | ||
invalid: [ | ||
'564785', | ||
'0123456789', | ||
'1437439210', | ||
'8009112340', | ||
'+10345672645', | ||
'11435213543', | ||
'2436119753', | ||
'16532116190', | ||
], | ||
}, | ||
{ | ||
|
Oops, something went wrong.