mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-09-04 18:20:03 +00:00
Adds name validation
This commit is contained in:
+12
-1
@@ -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
@@ -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([
|
||||
|
||||
Reference in New Issue
Block a user