mailtrain/lib/helpers.js
Tomas Bures 63765f7222 Client's public folder renamed to static
Regular campaign sender seems to have most of the code in place. (Not tested.)
2018-09-18 10:30:13 +02:00

30 lines
No EOL
512 B
JavaScript

'use strict';
let _ = require('./translate')._;
module.exports = {
enforce,
cleanupFromPost,
filterObject
};
function enforce(condition, message) {
if (!condition) {
throw new Error(message);
}
}
function cleanupFromPost(value) {
return (value || '').toString().trim();
}
function filterObject(obj, allowedKeys) {
const result = {};
for (const key in obj) {
if (allowedKeys.has(key)) {
result[key] = obj[key];
}
}
return result;
}