Adds name validation

This commit is contained in:
Akshay Nair
2020-10-04 13:30:15 +05:30
parent 5e20f5ea74
commit e042b69b2a
2 changed files with 16 additions and 5 deletions
+12 -1
View File
@@ -10,9 +10,20 @@ describe('Domains', () => {
});
});
describe('isValidDomainData', () => {
describe('validateDomainData', () => {
it('should return true if the name is invalid', () => {
const { valid, errors } = validateDomainData({
name: 'hello world',
forceHttps: true,
record: { CNAME: ['hello.com'] },
});
expect(valid).toBe(false);
expect(errors[0][0]).toBe('name');
});
it('should return true for a valid object', () => {
const { valid, errors } = validateDomainData({
name: 'something',
forceHttps: true,
record: { CNAME: ['hello.com'] },
});
+4 -4
View File
@@ -24,10 +24,10 @@ const validate = pattern => data => R.compose(
)(pattern);
const validateDomainData = validate({
//name: {
//reason: 'The name of the file is invalid',
//fn: R.match(/[A-Za-z0-9]{3,}/g),
//},
name: {
reason: 'The name of the file is invalid',
fn: str => str.match(/^[A-Za-z0-9]{3,}$/ig),
},
description: {
reason: 'Description has to be shorter than 100 characters',
fn: R.anyPass([