package link.at17.mid.tushare.data.validator;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import org.springframework.scheduling.support.CronExpression;

public class CronValidator implements ConstraintValidator<ValidCron, String> {

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        if (value == null || value.isBlank()) return true; // 空值交由 @NotBlank 处理
        try {
            CronExpression.parse(value);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
}