0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Merge pull request #5844 from ErisDS/validation-fix

Add underscores to general validation
This commit is contained in:
Sebastian Gierlinger 2015-09-18 11:24:04 +02:00
commit ef6a99fb34
2 changed files with 4 additions and 4 deletions

View file

@ -126,7 +126,7 @@ utils = {
errors = errors.concat(validation.validate(value, key, globalValidations[key]));
} else {
// all other keys should be an alphanumeric string + -, like slug, tag, author, status, etc
errors = errors.concat(validation.validate(value, key, {matches: /^[a-z0-9\-]+$/}));
errors = errors.concat(validation.validate(value, key, {matches: /^[a-z0-9\-_]+$/}));
}
}
});

View file

@ -217,9 +217,9 @@ describe('API Utils', function () {
check('limit', valid, invalid);
});
it('can validate `slug` or `status` or `author` etc as a-z, 0-9 and -', function () {
valid = ['hello-world', 'hello', '1-2-3', 1, '-1', -1];
invalid = ['hello_world', '!things', '?other-things', 'thing"', '`ticks`'];
it('can validate `slug` or `status` or `author` etc as a-z, 0-9, - and _', function () {
valid = ['hello-world', 'hello', '1-2-3', 1, '-1', -1, 'hello_world'];
invalid = ['hello~world', '!things', '?other-things', 'thing"', '`ticks`'];
check('slug', valid, invalid);
check('status', valid, invalid);