diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/helpers/validation-helpers.js | 10 | ||||
-rw-r--r-- | src/i18n/messages/src/helpers/validation-helpers.json | 20 |
2 files changed, 12 insertions, 18 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 | ||
diff --git a/src/i18n/messages/src/helpers/validation-helpers.json b/src/i18n/messages/src/helpers/validation-helpers.json index 86bfe1500..6be1d33e9 100644 --- a/src/i18n/messages/src/helpers/validation-helpers.json +++ b/src/i18n/messages/src/helpers/validation-helpers.json | |||
@@ -4,11 +4,11 @@ | |||
4 | "defaultMessage": "!!!Field is required", | 4 | "defaultMessage": "!!!Field is required", |
5 | "file": "src/helpers/validation-helpers.js", | 5 | "file": "src/helpers/validation-helpers.js", |
6 | "start": { | 6 | "start": { |
7 | "line": 4, | 7 | "line": 5, |
8 | "column": 12 | 8 | "column": 12 |
9 | }, | 9 | }, |
10 | "end": { | 10 | "end": { |
11 | "line": 7, | 11 | "line": 8, |
12 | "column": 3 | 12 | "column": 3 |
13 | } | 13 | } |
14 | }, | 14 | }, |
@@ -17,11 +17,11 @@ | |||
17 | "defaultMessage": "!!!Email not valid", | 17 | "defaultMessage": "!!!Email not valid", |
18 | "file": "src/helpers/validation-helpers.js", | 18 | "file": "src/helpers/validation-helpers.js", |
19 | "start": { | 19 | "start": { |
20 | "line": 8, | 20 | "line": 9, |
21 | "column": 9 | 21 | "column": 9 |
22 | }, | 22 | }, |
23 | "end": { | 23 | "end": { |
24 | "line": 11, | 24 | "line": 12, |
25 | "column": 3 | 25 | "column": 3 |
26 | } | 26 | } |
27 | }, | 27 | }, |
@@ -30,11 +30,11 @@ | |||
30 | "defaultMessage": "!!!Not a valid URL", | 30 | "defaultMessage": "!!!Not a valid URL", |
31 | "file": "src/helpers/validation-helpers.js", | 31 | "file": "src/helpers/validation-helpers.js", |
32 | "start": { | 32 | "start": { |
33 | "line": 12, | 33 | "line": 13, |
34 | "column": 7 | 34 | "column": 7 |
35 | }, | 35 | }, |
36 | "end": { | 36 | "end": { |
37 | "line": 15, | 37 | "line": 16, |
38 | "column": 3 | 38 | "column": 3 |
39 | } | 39 | } |
40 | }, | 40 | }, |
@@ -43,11 +43,11 @@ | |||
43 | "defaultMessage": "!!!Too few characters", | 43 | "defaultMessage": "!!!Too few characters", |
44 | "file": "src/helpers/validation-helpers.js", | 44 | "file": "src/helpers/validation-helpers.js", |
45 | "start": { | 45 | "start": { |
46 | "line": 16, | 46 | "line": 17, |
47 | "column": 13 | 47 | "column": 13 |
48 | }, | 48 | }, |
49 | "end": { | 49 | "end": { |
50 | "line": 19, | 50 | "line": 20, |
51 | "column": 3 | 51 | "column": 3 |
52 | } | 52 | } |
53 | }, | 53 | }, |
@@ -56,11 +56,11 @@ | |||
56 | "defaultMessage": "!!!At least one is required", | 56 | "defaultMessage": "!!!At least one is required", |
57 | "file": "src/helpers/validation-helpers.js", | 57 | "file": "src/helpers/validation-helpers.js", |
58 | "start": { | 58 | "start": { |
59 | "line": 20, | 59 | "line": 21, |
60 | "column": 15 | 60 | "column": 15 |
61 | }, | 61 | }, |
62 | "end": { | 62 | "end": { |
63 | "line": 23, | 63 | "line": 24, |
64 | "column": 3 | 64 | "column": 3 |
65 | } | 65 | } |
66 | } | 66 | } |