mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-22 14:01:42 +03:00
fix(Cron Parser): handle more patterns
Just use validation of cronstrue package Fix #855
This commit is contained in:
1 parent
cb5b462e11
commit
f1044b3e2b
1 file changed
+10
-5
@@ -1,12 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import cronstrue from 'cronstrue';
|
import cronstrue from 'cronstrue';
|
||||||
import { isValidCron } from 'cron-validator';
|
|
||||||
import { useStyleStore } from '@/stores/style.store';
|
import { useStyleStore } from '@/stores/style.store';
|
||||||
|
|
||||||
function isCronValid(v: string) {
|
|
||||||
return isValidCron(v, { allowBlankDay: true, alias: true, seconds: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
const styleStore = useStyleStore();
|
const styleStore = useStyleStore();
|
||||||
|
|
||||||
const cron = ref('40 * * * *');
|
const cron = ref('40 * * * *');
|
||||||
@@ -17,6 +12,16 @@ const cronstrueConfig = reactive({
|
|||||||
throwExceptionOnParseError: true,
|
throwExceptionOnParseError: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function isCronValid(v: string) {
|
||||||
|
try {
|
||||||
|
cronstrue.toString(v, cronstrueConfig);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (_) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const helpers = [
|
const helpers = [
|
||||||
{
|
{
|
||||||
symbol: '*',
|
symbol: '*',
|
||||||
|
|||||||
Reference in new issue
Block a user