Adds url rule validation

This commit is contained in:
Akshay Nair
2020-10-05 00:45:30 +05:30
parent 99dc783e16
commit 8e8fe46b2f
2 changed files with 4 additions and 1 deletions
+1
View File
@@ -49,6 +49,7 @@ describe('validateDomainData', () => {
...defaultDomain,
description: getstroflen(99),
},
{ ...defaultDomain, record: { CNAME: ['sd'], URL: ['121,3213'] } },
];
it('should return false for invalid data', () => {
+3 -1
View File
@@ -26,7 +26,7 @@ const validate = pattern => data => R.compose(
)(pattern);
const validateNameRecord = type => R.allPass([
R.compose(R.equals(1), R.length, R.keys),
R.compose(R.equals(1), R.length, R.reject(R.equals('URL')), R.keys),
R.propSatisfies(R.is(Array), type),
]);
@@ -59,10 +59,12 @@ const validateDomainData = validate({
reason: 'Invalid record',
fn: R.allPass([
R.is(Object),
//r => R.keys(r).
R.cond([
[R.prop('CNAME'), validateNameRecord('CNAME')],
[R.prop('ALIAS'), validateNameRecord('ALIAS')],
[R.prop('A'), R.propSatisfies(R.is(Array), 'A')],
[R.prop('URL'), R.propSatisfies(R.is(Array), 'URL')],
[R.T, R.T],
]),
]),