Add regex for restriction and use.

This commit is contained in:
Simon Vareille
2020-02-08 12:15:36 +01:00
parent fe9bf831e5
commit 919a984471
2 changed files with 19 additions and 6 deletions

View File

@@ -78,6 +78,19 @@ exports.isEmail = function(data) {
return re.test(data);
};
/**
* Checks for a valid specific organisation email address.
* @param {string} data The email address
* @return {boolean} Wether the email address comes from organisation
*/
exports.isFromOrganisation = function(data) {
if (!this.isString(data)) {
return false;
}
const re = /^([a-z0-9\-.]+)@([a-z0-9.\-]*)esisar\.grenoble-inp\.fr$/;
return re.test(data);
};
/**
* Normalize email address to lowercase.
* @param {string} email The email address