mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-07-04 03:42:21 -04:00
fix(Cron Parser): handle more patterns
Just use validation of cronstrue package Fix #855
This commit is contained in:
parent
cb5b462e11
commit
f1044b3e2b
1 changed files with 10 additions and 5 deletions
|
@ -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: '*',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue