later icon indicating copy to clipboard operation
later copied to clipboard

schedule returning isValid() = true but next(10) returns an array of undefineds

Open netei opened this issue 10 years ago • 4 comments

var s2 = {
  "schedules": [{"m":[0,15,30,45],s:0}],
  "exceptions":[]
};

var n1 = later.schedule(s2).isValid();
var n2 = later.schedule(s2).next(10);
console.log(n1);
console.log(n2);

outputs :

true
[ undefined,
  undefined,
  undefined,
  undefined,
  undefined,
  undefined,
  undefined,
  undefined,
  undefined,
  undefined ]

I now know that the s key needs to be an array : [0] instead of 0.

Still, I think it is a bug that the isValid() returns true, isn't it ?

netei avatar Dec 07 '15 16:12 netei

isValid(date) is used to determine if a particular date is valid based on the schedule, not if the schedule itself is valid. It unfortunately returns true for invalid schedules as a side affect of assuming that the schedule is properly formed. Is might be interesting to add a isScheduleValid() function but that doesn't currently exist.

bunkat avatar Dec 07 '15 17:12 bunkat

Ok, I get that, isScheduleValid would indeed be helpful

netei avatar Dec 08 '15 07:12 netei

So how to validate if the current date is valid to a schedule?

fabiomig avatar Feb 10 '16 12:02 fabiomig

Is there a way to validate a cron expression in this library ?

jeandat avatar Jun 26 '17 12:06 jeandat