Repository URL to install this package:
|
Version:
3.13.3 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isEmailValidForWhitelist = exports["default"] = isEmailValidForWhitelist;
exports.STRICT_EMAIL_REGEX = exports.TEXT_WITH_NAME_REGEX = void 0;
/**
* Is validating inputs for the MultiEmailSelect component.
* We need to allow domains and sub domains starting with a @ here as well
* @param {String} string
*/
function isEmailValidForWhitelist(string) {
var emailRE = new RegExp(/^(.*)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);
return emailRE.test(typeof string === 'string' && string || '');
}
/**
* This regex matches text of the following forms:
* name <something>
* name (something)
* "name" <something> (other valid quote symbols: „"'‚)
* email@domain
*
*
* The regex is made out of the two following parts:
*
* (?:([^,;@]+?)\s<)?
* An optional name. It checks whether the string is preceded by some text that does not contain a comma, semicolon
* or @ symbol. The quotes are removed in a second step. If a name is present, the next string must be contained in angle
* brackets "<" and ">" or normal brackets "(" and ")".
*
* (?:([^\s<(,]+@[^\s,;)>]+)>?)
* Basically checks that the thing contains any characters that can be accepted.
* This excludes commas and semicolons. This allows invalid emails in the above format to be accepted
* into the input and later on will be flagged up as an invald entry.
*/
// eslint-disable-next-line no-useless-escape
var TEXT_WITH_NAME_REGEX = /(?:([^,;@]+?)\s[<|\(])?(?:([^\s<(,;)>]+)[>|\)]?)/g;
/**
* This one is the one the type="email" input uses internally, provided by MDN.
*/
exports.TEXT_WITH_NAME_REGEX = TEXT_WITH_NAME_REGEX;
var STRICT_EMAIL_REGEX = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
exports.STRICT_EMAIL_REGEX = STRICT_EMAIL_REGEX;