later icon indicating copy to clipboard operation
later copied to clipboard

[fix] later.schedule().isValid returns true even when the passed schedule is not.

Open mat813 opened this issue 2 years ago • 0 comments

Describe the bug

  • Later version: 4.1.0
  • Node.js version: v16.13.2
  • OS & version: Arch Linux updated yesterday

When later.parse.text has errors, passing its result to later.schedule gives valid schedule

Actual behavior

If I give an invalid text string to later.parse.text, say, at 20h, the result has errors but when passed to later.schedule, it generates something that is correct, but never runs. It breaks Bree, which runs (in src/job-utils.js):

    const schedule = later.schedule(later.parse.text(value));
    if (schedule.isValid()) return later.parse.text(value);

Expected behavior

I expect isValid to return false when the schedule is not valid.

Code to reproduce

> later.parse.text('at 20h').error
3
> later.schedule(later.parse.text('at 20h')).isValid()
true

Checklist

  • [x] I have read the documentation.
  • [x] I have tried my code with the latest version of Node.js and @breejs/later.

mat813 avatar Apr 22 '22 08:04 mat813