MCPcopy
hub / github.com/node-cron/node-cron / isInvalidWeekDay

Function isInvalidWeekDay

src/pattern/validation/pattern-validation.ts:80–89  ·  view source on GitHub ↗

* @param {string} expression The Cron-Job expression. * @returns {boolean}

(expression)

Source from the content-addressed store, hash-verified

78 * @returns {boolean}
79 */
80function isInvalidWeekDay(expression) {
81 // `<weekday>#<nth>` (e.g. `2#3`, "the 3rd Tuesday") and `<weekday>L` (e.g.
82 // `5L`, "the last Friday") are valid tokens in this field only. The weekday
83 // is 0-7 (0 or 7 = Sunday); the `#` occurrence is 1-5. Any remaining entries
84 // must still be valid weekday numbers. Malformed forms (bare `L`, `L5`,
85 // `8L`, `2#6`, ...) never become tokens, so they fall through and are
86 // rejected.
87 const days = expression.filter((value) => !isNthWeekdayToken(value) && !/^[0-7]L$/.test(value));
88 return !isValidExpression(days, 0, 7);
89}
90
91/**
92 * @param {string[]} patterns The Cron-Job expression patterns.

Callers 1

validateFieldsFunction · 0.85

Calls 2

isNthWeekdayTokenFunction · 0.90
isValidExpressionFunction · 0.85

Tested by

no test coverage detected