Skip to content

Commit

Permalink
#984: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed Oct 11, 2023
1 parent 8e2670a commit 9981086
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions docs/dist/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -7837,7 +7837,7 @@ Util that contains logger and simple util methods
* [.isFalse(attrValue)](#Util.isFalse) ⇒ <code>boolean</code>
* [._isValidType(selectedType, [handleOutside])](#Util._isValidType) ⇒ <code>boolean</code>
* [.getTypeAndSubType(selectedType)](#Util.getTypeAndSubType) ⇒ <code>Array.&lt;string&gt;</code>
* [.emailValidator(email)](#Util.emailValidator) ⇒ <code>boolean</code>
* [.isEmailValid(email)](#Util.isEmailValid) ⇒ <code>boolean</code>
* [.getRetrieveTypeChoices()](#Util.getRetrieveTypeChoices) ⇒ <code>Array.&lt;TYPE.SupportedMetadataTypes&gt;</code>
* [._createNewLoggerTransport([noLogFile])](#Util._createNewLoggerTransport) ⇒ <code>object</code>
* [.startLogger([restart], [noLogFile])](#Util.startLogger) ⇒ <code>void</code>
Expand Down Expand Up @@ -7991,9 +7991,9 @@ helper that deals with extracting type and subtype
| --- | --- | --- |
| selectedType | <code>string</code> | "type" or "type-subtype" |

<a name="Util.emailValidator"></a>
<a name="Util.isEmailValid"></a>

### Util.emailValidator(email) ⇒ <code>boolean</code>
### Util.isEmailValid(email) ⇒ <code>boolean</code>
helper that validates email address

**Kind**: static method of [<code>Util</code>](#Util)
Expand Down
8 changes: 4 additions & 4 deletions lib/metadataTypes/Automation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1730,7 +1730,7 @@ class Automation extends MetadataType {
(notification) => notification.notificationType == 'Complete'
)?.body;
for (const email of completionEmail) {
if (oldCompletionEmails.includes(email) || !Util.emailValidator(email)) {
if (oldCompletionEmails.includes(email) || !Util.isEmailValid(email)) {
Util.logger.info(
` ☇ skipping ${email}- this email address is already in the notifications or is not a valid email`
);
Expand All @@ -1748,7 +1748,7 @@ class Automation extends MetadataType {
(notification) => notification.notificationType == 'Error'
)?.body;
for (const email of errorEmail) {
if (oldErrorEmails.includes(email) || !Util.emailValidator(email)) {
if (oldErrorEmails.includes(email) || !Util.isEmailValid(email)) {
Util.logger.info(
` ☇ skipping ${email}- this email address is already in the notifications or is not a valid email`
);
Expand Down Expand Up @@ -1785,7 +1785,7 @@ class Automation extends MetadataType {
// completionEmail is an array even if there is only one email
if (completionEmail.length > 0) {
for (const email of completionEmail) {
if (Util.emailValidator(email)) {
if (Util.isEmailValid(email)) {
notificationBody.workers.push({
programId: automationLegacyMapObj.metadata[key].id,
notificationType: 'Complete',
Expand Down Expand Up @@ -1815,7 +1815,7 @@ class Automation extends MetadataType {
}
if (errorEmail.length > 0) {
for (const email of errorEmail) {
if (Util.emailValidator(email)) {
if (Util.isEmailValid(email)) {
notificationBody.workers.push({
programId: automationLegacyMapObj.metadata[key].id,
notificationType: 'Error',
Expand Down
4 changes: 2 additions & 2 deletions lib/util/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ const Cli = {
return emails
.split(',')
.map((email) => {
if (!Util.emailValidator(email)) {
if (!Util.isEmailValid(email)) {
Util.logger.info(` ☇ skipping ${email}' - invalid email address`);
}
return email.trim();
})
.filter((email) => Util.emailValidator(email));
.filter((email) => Util.isEmailValid(email));
},
}
);
Expand Down
2 changes: 1 addition & 1 deletion lib/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export const Util = {
* @param {string} email email to validate
* @returns {boolean} first elem is type, second elem is subType
*/
emailValidator(email) {
isEmailValid(email) {
const regex = new RegExp(
"^([!#-'*+/-9=?A-Z^-~-]+(.[!#-'*+/-9=?A-Z^-~-]+)*|\"([]!#-[^-~ \\t]|(\\[\\t -~]))+\")@([!#-'*+/-9=?A-Z^-~-]+(.[!#-'*+/-9=?A-Z^-~-]+)*|[[\\t -Z^-~]*])$"
);
Expand Down

0 comments on commit 9981086

Please sign in to comment.