diff options
author | 2019-06-06 12:39:36 +0200 | |
---|---|---|
committer | 2019-06-06 12:39:36 +0200 | |
commit | 53e26cbebbb0c00c5d2d0faaeb40bd2f42e18336 (patch) | |
tree | d22598c89c382825138bea0e844d77facb559541 /src/helpers/validation-helpers.js | |
parent | Merge pull request #1467 from meetfranz/fix/windows-close-window-shortcut (diff) | |
download | ferdium-app-53e26cbebbb0c00c5d2d0faaeb40bd2f42e18336.tar.gz ferdium-app-53e26cbebbb0c00c5d2d0faaeb40bd2f42e18336.tar.zst ferdium-app-53e26cbebbb0c00c5d2d0faaeb40bd2f42e18336.zip |
Use same email validation as on the api
Diffstat (limited to 'src/helpers/validation-helpers.js')
-rw-r--r-- | src/helpers/validation-helpers.js | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/helpers/validation-helpers.js b/src/helpers/validation-helpers.js index 2f762437d..ab2376b1b 100644 --- a/src/helpers/validation-helpers.js +++ b/src/helpers/validation-helpers.js | |||
@@ -1,4 +1,5 @@ | |||
1 | import { defineMessages } from 'react-intl'; | 1 | import { defineMessages } from 'react-intl'; |
2 | import isEmail from 'validator/lib/isEmail'; | ||
2 | 3 | ||
3 | const messages = defineMessages({ | 4 | const messages = defineMessages({ |
4 | required: { | 5 | required: { |
@@ -30,14 +31,7 @@ export function required({ field }) { | |||
30 | 31 | ||
31 | export function email({ field }) { | 32 | export function email({ field }) { |
32 | const value = field.value.trim(); | 33 | const value = field.value.trim(); |
33 | let isValid = false; | 34 | const isValid = isEmail(value); |
34 | |||
35 | if (value !== '') { | ||
36 | isValid = Boolean(value.match(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,63}/i)); | ||
37 | } else { | ||
38 | isValid = true; | ||
39 | } | ||
40 | |||
41 | return [isValid, window.franz.intl.formatMessage(messages.email, { field: field.label })]; | 35 | return [isValid, window.franz.intl.formatMessage(messages.email, { field: field.label })]; |
42 | } | 36 | } |
43 | 37 | ||