diff options
-rw-r--r-- | package-lock.json | 5 | ||||
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | src/helpers/validation-helpers.js | 10 | ||||
-rw-r--r-- | src/i18n/locales/defaultMessages.json | 20 | ||||
-rw-r--r-- | src/i18n/messages/src/helpers/validation-helpers.json | 20 |
5 files changed, 28 insertions, 28 deletions
diff --git a/package-lock.json b/package-lock.json index 2fd2e4681..8a92d6136 100644 --- a/package-lock.json +++ b/package-lock.json | |||
@@ -20041,6 +20041,11 @@ | |||
20041 | "builtins": "^1.0.3" | 20041 | "builtins": "^1.0.3" |
20042 | } | 20042 | } |
20043 | }, | 20043 | }, |
20044 | "validator": { | ||
20045 | "version": "11.0.0", | ||
20046 | "resolved": "https://registry.npmjs.org/validator/-/validator-11.0.0.tgz", | ||
20047 | "integrity": "sha512-+wnGLYqaKV2++nUv60uGzUJyJQwYVOin6pn1tgEiFCeCQO60yeu3Og9/yPccbBX574kxIcEJicogkzx6s6eyag==" | ||
20048 | }, | ||
20044 | "value-or-function": { | 20049 | "value-or-function": { |
20045 | "version": "3.0.0", | 20050 | "version": "3.0.0", |
20046 | "resolved": "https://registry.npmjs.org/value-or-function/-/value-or-function-3.0.0.tgz", | 20051 | "resolved": "https://registry.npmjs.org/value-or-function/-/value-or-function-3.0.0.tgz", |
diff --git a/package.json b/package.json index 8908d59f6..a0305554d 100644 --- a/package.json +++ b/package.json | |||
@@ -86,6 +86,7 @@ | |||
86 | "smoothscroll-polyfill": "^0.3.4", | 86 | "smoothscroll-polyfill": "^0.3.4", |
87 | "tar": "^4.0.2", | 87 | "tar": "^4.0.2", |
88 | "uuid": "^3.0.1", | 88 | "uuid": "^3.0.1", |
89 | "validator": "11.0.0", | ||
89 | "ws": "6.2.1" | 90 | "ws": "6.2.1" |
90 | }, | 91 | }, |
91 | "devDependencies": { | 92 | "devDependencies": { |
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/locales/defaultMessages.json b/src/i18n/locales/defaultMessages.json index 9524238f0..0d5c526fa 100644 --- a/src/i18n/locales/defaultMessages.json +++ b/src/i18n/locales/defaultMessages.json | |||
@@ -3759,65 +3759,65 @@ | |||
3759 | "defaultMessage": "!!!Field is required", | 3759 | "defaultMessage": "!!!Field is required", |
3760 | "end": { | 3760 | "end": { |
3761 | "column": 3, | 3761 | "column": 3, |
3762 | "line": 7 | 3762 | "line": 8 |
3763 | }, | 3763 | }, |
3764 | "file": "src/helpers/validation-helpers.js", | 3764 | "file": "src/helpers/validation-helpers.js", |
3765 | "id": "validation.required", | 3765 | "id": "validation.required", |
3766 | "start": { | 3766 | "start": { |
3767 | "column": 12, | 3767 | "column": 12, |
3768 | "line": 4 | 3768 | "line": 5 |
3769 | } | 3769 | } |
3770 | }, | 3770 | }, |
3771 | { | 3771 | { |
3772 | "defaultMessage": "!!!Email not valid", | 3772 | "defaultMessage": "!!!Email not valid", |
3773 | "end": { | 3773 | "end": { |
3774 | "column": 3, | 3774 | "column": 3, |
3775 | "line": 11 | 3775 | "line": 12 |
3776 | }, | 3776 | }, |
3777 | "file": "src/helpers/validation-helpers.js", | 3777 | "file": "src/helpers/validation-helpers.js", |
3778 | "id": "validation.email", | 3778 | "id": "validation.email", |
3779 | "start": { | 3779 | "start": { |
3780 | "column": 9, | 3780 | "column": 9, |
3781 | "line": 8 | 3781 | "line": 9 |
3782 | } | 3782 | } |
3783 | }, | 3783 | }, |
3784 | { | 3784 | { |
3785 | "defaultMessage": "!!!Not a valid URL", | 3785 | "defaultMessage": "!!!Not a valid URL", |
3786 | "end": { | 3786 | "end": { |
3787 | "column": 3, | 3787 | "column": 3, |
3788 | "line": 15 | 3788 | "line": 16 |
3789 | }, | 3789 | }, |
3790 | "file": "src/helpers/validation-helpers.js", | 3790 | "file": "src/helpers/validation-helpers.js", |
3791 | "id": "validation.url", | 3791 | "id": "validation.url", |
3792 | "start": { | 3792 | "start": { |
3793 | "column": 7, | 3793 | "column": 7, |
3794 | "line": 12 | 3794 | "line": 13 |
3795 | } | 3795 | } |
3796 | }, | 3796 | }, |
3797 | { | 3797 | { |
3798 | "defaultMessage": "!!!Too few characters", | 3798 | "defaultMessage": "!!!Too few characters", |
3799 | "end": { | 3799 | "end": { |
3800 | "column": 3, | 3800 | "column": 3, |
3801 | "line": 19 | 3801 | "line": 20 |
3802 | }, | 3802 | }, |
3803 | "file": "src/helpers/validation-helpers.js", | 3803 | "file": "src/helpers/validation-helpers.js", |
3804 | "id": "validation.minLength", | 3804 | "id": "validation.minLength", |
3805 | "start": { | 3805 | "start": { |
3806 | "column": 13, | 3806 | "column": 13, |
3807 | "line": 16 | 3807 | "line": 17 |
3808 | } | 3808 | } |
3809 | }, | 3809 | }, |
3810 | { | 3810 | { |
3811 | "defaultMessage": "!!!At least one is required", | 3811 | "defaultMessage": "!!!At least one is required", |
3812 | "end": { | 3812 | "end": { |
3813 | "column": 3, | 3813 | "column": 3, |
3814 | "line": 23 | 3814 | "line": 24 |
3815 | }, | 3815 | }, |
3816 | "file": "src/helpers/validation-helpers.js", | 3816 | "file": "src/helpers/validation-helpers.js", |
3817 | "id": "validation.oneRequired", | 3817 | "id": "validation.oneRequired", |
3818 | "start": { | 3818 | "start": { |
3819 | "column": 15, | 3819 | "column": 15, |
3820 | "line": 20 | 3820 | "line": 21 |
3821 | } | 3821 | } |
3822 | } | 3822 | } |
3823 | ], | 3823 | ], |
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 | } |