This commit is contained in:
Akshay Nair
2020-10-17 22:03:12 +05:30
parent 7570136908
commit 732f76a557
4 changed files with 34 additions and 6 deletions
+6
View File
@@ -9,6 +9,12 @@
},
"rules": {
"indent": ["error", 2],
"max-len": ["error", {
"code": 100,
"ignoreStrings": true,
"ignoreTemplateLiterals": true,
"ignoreTrailingComments": true
}],
"node/exports-style": ["error", "module.exports"],
"node/file-extension-in-import": ["error", "always"],
"node/prefer-global/buffer": ["error", "always"],
+7 -1
View File
@@ -6,7 +6,13 @@ if (!CI) {
require('dotenv').config({ path: path.resolve(`.env.${ENV}`) });
}
const { DOMAIN_USER, DOMAIN_API_KEY, DOMAIN_DOMAIN, DOMAIN_API_HOST, DOMAIN_API_PORT } = process.env;
const {
DOMAIN_USER,
DOMAIN_API_KEY,
DOMAIN_DOMAIN,
DOMAIN_API_HOST,
DOMAIN_API_PORT,
} = process.env;
const IS_TEST = ENV === 'test';
+20 -2
View File
@@ -8,7 +8,9 @@ const between = (min, max) => num => num >= min && num <= max;
const testRegex = regex => str => !!(str && str.match(regex));
const validate = pattern => data => R.compose(
invalidPairs => invalidPairs.length ? { errors: invalidPairs, valid: false } : { errors: [], valid: true },
invalidPairs => invalidPairs.length
? { errors: invalidPairs, valid: false }
: { errors: [], valid: true },
R.filter(([key, { fn }]) => fn ? !fn(data[key]) : false),
R.toPairs,
)(pattern);
@@ -30,5 +32,21 @@ const batchLazyTasks = count => tasks => tasks.reduce((batches, task) => {
return [...full, [...last, task]];
}, []);
module.exports = { or, and, validate, between, testRegex, log, print, then, lazyTask, batchLazyTasks };
const withLengthGte = n => R.compose(R.gte(R.__, n), R.length);
const withLengthEq = n => R.compose(R.equals(n), R.length);
module.exports = {
or,
and,
validate,
between,
testRegex,
log,
print,
then,
lazyTask,
batchLazyTasks,
withLengthEq,
withLengthGte,
};
+1 -3
View File
@@ -1,8 +1,6 @@
const R = require('ramda');
const { VALID_RECORD_TYPES } = require('./constants');
const { or, and, validate, between, testRegex } = require('./helpers');
const withLengthGte = n => R.compose(R.gte(R.__, n), R.length);
const withLengthEq = n => R.compose(R.equals(n), R.length);
const { or, and, validate, between, testRegex, withLengthEq, withLengthGte } = require('./helpers');
const validateCnameRecord = key => and([
R.propSatisfies(R.is(String), key),