aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Dominik Guzei <dominik.guzei@gmail.com>2019-06-06 12:39:36 +0200
committerLibravatar Dominik Guzei <dominik.guzei@gmail.com>2019-06-06 12:39:36 +0200
commit53e26cbebbb0c00c5d2d0faaeb40bd2f42e18336 (patch)
treed22598c89c382825138bea0e844d77facb559541
parentMerge pull request #1467 from meetfranz/fix/windows-close-window-shortcut (diff)
downloadferdium-app-53e26cbebbb0c00c5d2d0faaeb40bd2f42e18336.tar.gz
ferdium-app-53e26cbebbb0c00c5d2d0faaeb40bd2f42e18336.tar.zst
ferdium-app-53e26cbebbb0c00c5d2d0faaeb40bd2f42e18336.zip
Use same email validation as on the api
-rw-r--r--package-lock.json7
-rw-r--r--package.json1
-rw-r--r--src/helpers/validation-helpers.js10
-rw-r--r--src/i18n/messages/src/helpers/validation-helpers.json20
4 files changed, 19 insertions, 19 deletions
diff --git a/package-lock.json b/package-lock.json
index fc328c4b4..a00e68da2 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
1{ 1{
2 "name": "franz", 2 "name": "franz",
3 "version": "5.0.1", 3 "version": "5.1.0",
4 "lockfileVersion": 1, 4 "lockfileVersion": 1,
5 "requires": true, 5 "requires": true,
6 "dependencies": { 6 "dependencies": {
@@ -20034,6 +20034,11 @@
20034 "builtins": "^1.0.3" 20034 "builtins": "^1.0.3"
20035 } 20035 }
20036 }, 20036 },
20037 "validator": {
20038 "version": "11.0.0",
20039 "resolved": "https://registry.npmjs.org/validator/-/validator-11.0.0.tgz",
20040 "integrity": "sha512-+wnGLYqaKV2++nUv60uGzUJyJQwYVOin6pn1tgEiFCeCQO60yeu3Og9/yPccbBX574kxIcEJicogkzx6s6eyag=="
20041 },
20037 "value-or-function": { 20042 "value-or-function": {
20038 "version": "3.0.0", 20043 "version": "3.0.0",
20039 "resolved": "https://registry.npmjs.org/value-or-function/-/value-or-function-3.0.0.tgz", 20044 "resolved": "https://registry.npmjs.org/value-or-function/-/value-or-function-3.0.0.tgz",
diff --git a/package.json b/package.json
index c1a8c310f..bfc06c005 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 @@
1import { defineMessages } from 'react-intl'; 1import { defineMessages } from 'react-intl';
2import isEmail from 'validator/lib/isEmail';
2 3
3const messages = defineMessages({ 4const messages = defineMessages({
4 required: { 5 required: {
@@ -30,14 +31,7 @@ export function required({ field }) {
30 31
31export function email({ field }) { 32export 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 }