fix(Cron Parser): handle more patterns

Just use validation of cronstrue package
Fix #855
This commit is contained in:
sharevb committed 2024-05-01 23:40:37 +02:00
1 parent cb5b462e11
commit f1044b3e2b
1 file changed
+10 -5
@@ -1,12 +1,7 @@
<script setup lang="ts">
import cronstrue from 'cronstrue';
import { isValidCron } from 'cron-validator';
import { useStyleStore } from '@/stores/style.store';
function isCronValid(v: string) {
return isValidCron(v, { allowBlankDay: true, alias: true, seconds: true });
}
const styleStore = useStyleStore();
const cron = ref('40 * * * *');
@@ -17,6 +12,16 @@ const cronstrueConfig = reactive({
throwExceptionOnParseError: true,
});
function isCronValid(v: string) {
try {
cronstrue.toString(v, cronstrueConfig);
return true;
}
catch (_) {
return false;
}
}
const helpers = [
{
symbol: '*',