修复添加任务有可能失败

This commit is contained in:
whyour
2026-07-01 00:37:42 +08:00
parent a0d57c78c5
commit e92ddb0aed
12 changed files with 194 additions and 58 deletions
+10
View File
@@ -12,6 +12,16 @@ const validateSchedule = (value: string, helpers: any) => {
return value;
}
// 检测裸 /N 模式:cron-parser 会接受,但 node-schedule 会返回 null
// 提前拦截,避免任务入库后调度器注册失败
if (/\s\/\d/.test(value) || /^\/\d/.test(value)) {
return helpers.error('any.invalid');
}
// 检测 ? 字符:Quartz cron 语法,node-schedule 在大多数字段上返回 null
if (/\?/.test(value)) {
return helpers.error('any.invalid');
}
try {
if (CronExpressionParser.parse(value).hasNext()) {
return value;