MCPcopy
hub / github.com/breejs/bree / validateCron

Function validateCron

src/job-validator.js:138–186  ·  view source on GitHub ↗
(job, prefix, config)

Source from the content-addressed store, hash-verified

136};
137
138const validateCron = (job, prefix, config) => {
139 const errors = [];
140
141 if (!isSchedule(job.cron)) {
142 // If `hasSeconds` was `true` then set `cronValidate` and inherit any existing options
143 const cronValidate = job.hasSeconds
144 ? cronValidateWithSeconds(job, config)
145 : job.cronValidate || config.cronValidate;
146
147 //
148 // validate cron pattern
149 // (must support patterns such as `* * L * *` and `0 0/5 14 * * ?` (and aliases too)
150 //
151 // <https://github.com/Airfooox/cron-validate/issues/67>
152 //
153 const result = cron(job.cron, cronValidate);
154
155 if (!result.isValid()) {
156 // NOTE: it is always valid
157 // const schedule = later.schedule(
158 // later.parse.cron(
159 // job.cron,
160 // boolean(
161 // typeof job.hasSeconds === 'undefined'
162 // ? config.hasSeconds
163 // : job.hasSeconds
164 // )
165 // )
166 // );
167 // if (schedule.isValid()) {
168 // job.interval = schedule;
169 // } // else {
170 // errors.push(
171 // new Error(
172 // `${prefix} had an invalid cron schedule (see <https://crontab.guru> if you need help)`
173 // )
174 // );
175 // }
176
177 for (const message of result.getError()) {
178 errors.push(
179 new Error(`${prefix} had an invalid cron pattern: ${message}`)
180 );
181 }
182 }
183 }
184
185 return errors;
186};
187
188const validateJobName = (job, i, reservedNames) => {
189 const errors = [];

Callers 1

validateFunction · 0.85

Calls 2

isScheduleFunction · 0.85
cronValidateWithSecondsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…