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 @@ { "name": "franz", - "version": "5.0.1", + "version": "5.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -20034,6 +20034,11 @@ "builtins": "^1.0.3" } }, + "validator": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/validator/-/validator-11.0.0.tgz", + "integrity": "sha512-+wnGLYqaKV2++nUv60uGzUJyJQwYVOin6pn1tgEiFCeCQO60yeu3Og9/yPccbBX574kxIcEJicogkzx6s6eyag==" + }, "value-or-function": { "version": "3.0.0", "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 @@ "smoothscroll-polyfill": "^0.3.4", "tar": "^4.0.2", "uuid": "^3.0.1", + "validator": "11.0.0", "ws": "6.2.1" }, "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 @@ 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 })]; } 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 @@ "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 } } ], 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 @@ "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 } }