Skip to content
Permalink
Browse files

fix(App): Improved email validation /cc @Snuggle

  • Loading branch information...
DominikGuzei committed Jun 6, 2019
2 parents 02f6c5f + e033131 commit dd8ddccfae1e9cee1aa9ed6b4550faca9524ae96

Some generated files are not rendered by default. Learn more.

@@ -86,6 +86,7 @@
"smoothscroll-polyfill": "^0.3.4",
"tar": "^4.0.2",
"uuid": "^3.0.1",
"validator": "11.0.0",
"ws": "6.2.1"
},
"devDependencies": {
@@ -1,4 +1,5 @@
import { defineMessages } from 'react-intl';
import isEmail from 'validator/lib/isEmail';

const messages = defineMessages({
required: {
@@ -30,14 +31,7 @@ export function required({ field }) {

export function email({ field }) {
const value = field.value.trim();
let isValid = false;

if (value !== '') {
isValid = Boolean(value.match(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,63}/i));
} else {
isValid = true;
}

const isValid = isEmail(value);
return [isValid, window.franz.intl.formatMessage(messages.email, { field: field.label })];
}

@@ -3759,65 +3759,65 @@
"defaultMessage": "!!!Field is required",
"end": {
"column": 3,
"line": 7
"line": 8
},
"file": "src/helpers/validation-helpers.js",
"id": "validation.required",
"start": {
"column": 12,
"line": 4
"line": 5
}
},
{
"defaultMessage": "!!!Email not valid",
"end": {
"column": 3,
"line": 11
"line": 12
},
"file": "src/helpers/validation-helpers.js",
"id": "validation.email",
"start": {
"column": 9,
"line": 8
"line": 9
}
},
{
"defaultMessage": "!!!Not a valid URL",
"end": {
"column": 3,
"line": 15
"line": 16
},
"file": "src/helpers/validation-helpers.js",
"id": "validation.url",
"start": {
"column": 7,
"line": 12
"line": 13
}
},
{
"defaultMessage": "!!!Too few characters",
"end": {
"column": 3,
"line": 19
"line": 20
},
"file": "src/helpers/validation-helpers.js",
"id": "validation.minLength",
"start": {
"column": 13,
"line": 16
"line": 17
}
},
{
"defaultMessage": "!!!At least one is required",
"end": {
"column": 3,
"line": 23
"line": 24
},
"file": "src/helpers/validation-helpers.js",
"id": "validation.oneRequired",
"start": {
"column": 15,
"line": 20
"line": 21
}
}
],
@@ -4,11 +4,11 @@
"defaultMessage": "!!!Field is required",
"file": "src/helpers/validation-helpers.js",
"start": {
"line": 4,
"line": 5,
"column": 12
},
"end": {
"line": 7,
"line": 8,
"column": 3
}
},
@@ -17,11 +17,11 @@
"defaultMessage": "!!!Email not valid",
"file": "src/helpers/validation-helpers.js",
"start": {
"line": 8,
"line": 9,
"column": 9
},
"end": {
"line": 11,
"line": 12,
"column": 3
}
},
@@ -30,11 +30,11 @@
"defaultMessage": "!!!Not a valid URL",
"file": "src/helpers/validation-helpers.js",
"start": {
"line": 12,
"line": 13,
"column": 7
},
"end": {
"line": 15,
"line": 16,
"column": 3
}
},
@@ -43,11 +43,11 @@
"defaultMessage": "!!!Too few characters",
"file": "src/helpers/validation-helpers.js",
"start": {
"line": 16,
"line": 17,
"column": 13
},
"end": {
"line": 19,
"line": 20,
"column": 3
}
},
@@ -56,11 +56,11 @@
"defaultMessage": "!!!At least one is required",
"file": "src/helpers/validation-helpers.js",
"start": {
"line": 20,
"line": 21,
"column": 15
},
"end": {
"line": 23,
"line": 24,
"column": 3
}
}

0 comments on commit dd8ddcc

Please sign in to comment.
You can’t perform that action at this time.