Skip to content

Commit f1044b3

Browse files
committed
fix(Cron Parser): handle more patterns
Just use validation of cronstrue package Fix CorentinTh#855
1 parent cb5b462 commit f1044b3

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/tools/crontab-generator/crontab-generator.vue

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
<script setup lang="ts">
22
import cronstrue from 'cronstrue';
3-
import { isValidCron } from 'cron-validator';
43
import { useStyleStore } from '@/stores/style.store';
54
6-
function isCronValid(v: string) {
7-
return isValidCron(v, { allowBlankDay: true, alias: true, seconds: true });
8-
}
9-
105
const styleStore = useStyleStore();
116
127
const cron = ref('40 * * * *');
@@ -17,6 +12,16 @@ const cronstrueConfig = reactive({
1712
throwExceptionOnParseError: true,
1813
});
1914
15+
function isCronValid(v: string) {
16+
try {
17+
cronstrue.toString(v, cronstrueConfig);
18+
return true;
19+
}
20+
catch (_) {
21+
return false;
22+
}
23+
}
24+
2025
const helpers = [
2126
{
2227
symbol: '*',

0 commit comments

Comments
 (0)