Skip to content
This repository was archived by the owner on Apr 19, 2022. It is now read-only.

Commit 125fe9f

Browse files
author
Markus Tacker
committed
Allow emails with address extension, e.g. [email protected]
1 parent bcd854b commit 125fe9f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/Raw/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const moment = require('moment')
1212
* list of creepy regex, no they work nice
1313
*/
1414
const urlRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/i
15-
const emailRegex = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
15+
const emailRegex = /^([\w-]+(?:\.[\w-]+)*)(\+[\w\.-]+)?@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
1616
const phoneRegex = /\b\d{3}[-.]?\d{3}[-.]?\d{4}\b/
1717
const creditCardRegex = /^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|6(?:011|5[0-9]{2})[0-9]{12}|(?:2131|1800|35\d{3})\d{11})$/
1818
const alphaNumericRegex = /^[a-z0-9]+$/i

test/validations.spec.js

+10
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,16 @@ describe('Validations', function() {
167167
expect(passes).to.equal('validation passed')
168168
})
169169

170+
it('should work fine when valid email with extension is provided', function * () {
171+
const data = {email:'[email protected]'}
172+
const field = 'email'
173+
const message = 'email must be email'
174+
const get = dotProp.get
175+
const args = []
176+
const passes = yield Validations.email(data, field, message, args, get)
177+
expect(passes).to.equal('validation passed')
178+
})
179+
170180
})
171181

172182
context('Accepted', function () {

0 commit comments

Comments
 (0)