Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: invalid value separator #419

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/pattern-validation.js
Expand Up @@ -112,6 +112,9 @@ function validateFields(patterns, executablePatterns) {
function validate(pattern) {
if (typeof pattern !== 'string')
throw new TypeError('pattern must be a string!');
const charRegex = new RegExp('^[a-zA-Z0-9-*/, ]+$');
if (!charRegex.test(pattern))
throw new TypeError('pattern includes illegal characters!');

const patterns = pattern.split(' ');
const executablePatterns = convertExpression(pattern).split(' ');
Expand Down
12 changes: 12 additions & 0 deletions test/pattern-validation/validate-test.js
Expand Up @@ -16,6 +16,18 @@ describe('pattern-validation', () => {
}).to.throw('60 is a invalid expression for minute');
});

it('should fail with invalid separator character', () => {
expect(() => {
validate('1;2;3 * * * *');
}).to.throw('pattern includes illegal characters!');
});

it('should not fail with valid separator character', () => {
expect(() => {
validate('1,2,3 * * * *');
}).to.not.throw();
});

it('should fail without a string', () => {
expect(() => {
validate(50);
Expand Down