Adds '@' rule for root domain

This commit is contained in:
Akshay Nair
2020-10-05 15:55:21 +05:30
parent 1e19df4544
commit da8ecd0c7b
3 changed files with 17 additions and 5 deletions
+9
View File
@@ -0,0 +1,9 @@
{
"owner": {
"username": "phenax",
"email": "phenax5@gmail.com"
},
"record": {
"URL": "https://www.is-a.dev"
}
}
+1 -1
View File
@@ -4,6 +4,6 @@
"email": "phenax5@gmail.com"
},
"record": {
"CNAME": "placeholder"
"CNAME": "placeholder.com"
}
}
+7 -4
View File
@@ -18,7 +18,7 @@ const getDomains = () =>
name: name.replace(/\.json$/, ''),
})));
const hasLengthLessThan = len => R.compose(R.not, R.lt(len), R.length);
const between = (min, max) => num => num >= min && num <= max;
const validate = pattern => data => R.compose(
invalidPairs => invalidPairs.length ? { errors: invalidPairs, valid: false } : { errors: [], valid: true },
@@ -34,9 +34,12 @@ const validateNameRecord = type => R.allPass([
const validateDomainData = validate({
name: {
reason: 'The name of the file is invalid',
fn: R.allPass([
hasLengthLessThan(100),
str => str && str.match(/^[A-Za-z0-9\-]{2,}$/ig),
fn: R.anyPass([
R.equals('@'),
R.allPass([
R.compose(between(2, 100), R.length),
str => str && str.match(/^[A-Za-z0-9\-]+$/ig),
])
]),
},
description: { reason: '', fn: R.T, },