-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved email validation to helper, changed logic for checking emails
- Loading branch information
1 parent
7c71762
commit 97221a4
Showing
3 changed files
with
28 additions
and
20 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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { helper } from '@ember/component/helper'; | ||
|
||
|
||
export function validateEmail(email) { | ||
// eslint-disable-next-line no-useless-escape | ||
const tester = /^[-!#$%&'*+\/0-9=?A-Z^_a-z{|}~](\.?[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-*\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/; | ||
if (!email) return false; | ||
|
||
if (email.length > 254) return false; | ||
|
||
const valid = tester.test(email); | ||
if (!valid) return false; | ||
|
||
// Further checking of some things regex can't handle | ||
const parts = email.split('@'); | ||
if (parts[0].length > 64) return false; | ||
|
||
const domainParts = parts[1].split('.'); | ||
if (domainParts.some(function(part) { return part.length > 63; })) return false; | ||
|
||
return true; | ||
} | ||
|
||
export default helper(validateEmail); |