fix: improve crontab validation logic

This commit is contained in:
wangruidong
2025-04-15 10:05:45 +08:00
committed by 老广
parent 47b72cb35e
commit 20070e0647

View File

@@ -189,8 +189,8 @@ class PeriodTaskSerializerMixin(serializers.Serializer):
msg = _('* Please enter a valid crontab expression')
raise serializers.ValidationError(msg)
crontab = crontab.strip().split()
if '*' in crontab[0]:
crontab = crontab.strip()
if crontab.startswith('*'):
raise serializers.ValidationError(_("Crontab minute must not contain '*'"))
return crontab