[lib.field-manager] 'basic-name' 'url-name' cannot have trailing spaces

This commit is contained in:
xdrm-brackets 2018-03-29 13:14:37 +02:00
parent 32f4e9a7b3
commit 1ea9a713b7
1 changed files with 2 additions and 2 deletions

View File

@ -15,12 +15,12 @@ FieldValidator.pushFormat('bypass', () => true);
/* (2) Basic name */
FieldValidator.pushFormat('basic-name', (input) => {
return typeof input === 'string' && /^[a-z0-9 _-]{3,20}$/i.test(input);
return typeof input === 'string' && input.trim() === input && /^[a-z0-9 _-]{3,20}$/i.test(input);
}, '3 characters required: letters, numbers, spaces, dots, hyphens');
/* (3) URL name */
FieldValidator.pushFormat('url-name', (input) => {
return typeof input === 'string' && /^[a-z0-9_-]{3,20}$/i.test(input);
return typeof input === 'string' && input.trim() === input && /^[a-z0-9_-]{3,20}$/i.test(input);
}, '3 characters required: letters, numbers, hyphens');
/* (4) Password */