fix(Cron Parser): handle more patterns

Just use validation of cronstrue package
Fix #855
This commit is contained in:
sharevb 2024-05-01 14:22:46 +02:00
parent cb5b462e11
commit f1044b3e2b

View file

@ -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: '*',