Skip to content

Commit

Permalink
Add cron validation case
Browse files Browse the repository at this point in the history
  • Loading branch information
shoonia committed May 8, 2024
1 parent 433d817 commit 324a955
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/util/parseCron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,25 @@ export const parseCron = (value: string): CronResult => {

if (LESS_HOUR.test(message)) {
return ex(
`${message}\n\nError: You can schedule your job to run at intervals as short as one hour apart, but not shorter. If you define your job to run more frequently, the job will be ignored.`,
`${message}\n\nError: You can schedule your job to run at intervals as short as one hour apart, but not shorter. If you define your job to run more frequently, the job will be ignored`,
);
}

if (value.includes('?')) {
return ex(
`${message}.\n\nError: Velo Job Scheduler does not support the blank syntax with (?) symbol.`,
`${message}.\n\nError: Velo Job Scheduler does not support the blank syntax with (?) symbol`,
);
}

if (value.includes('#')) {
return ex(
`${message}.\n\nError: Velo Job Scheduler does not support the hash (#) symbol.`,
`${message}.\n\nError: Velo Job Scheduler does not support the hash (#) symbol`,
);
}

if (value.startsWith('@')) {
return ex(
`${message}.\n\nError: Velo Job Scheduler does not support the @options syntax (i.e., @daily, @weekly, @monthly, @yearly, and so on)`
);
}

Expand All @@ -46,7 +52,7 @@ export const parseCron = (value: string): CronResult => {
}

return ex(
`${message}.\n\nError: Velo Job Scheduler does not support this syntax.`,
`${message}.\n\nError: Velo Job Scheduler does not support this syntax`,
);
} catch (error) {
return ex(String(error));
Expand Down

0 comments on commit 324a955

Please sign in to comment.