Skip to content

Commit f6a0c53

Browse files
committed
feat: add allowStepping option (#290)
1 parent 532fedb commit f6a0c53

File tree

5 files changed

+106
-72
lines changed

5 files changed

+106
-72
lines changed

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ registerOptionPreset('YOUR-PRESET-ID', {
9797
useAliases: false, // optional, default to false
9898
useBlankDay: false,
9999
allowOnlyOneBlankDayField: false,
100+
allowStepping: true, // optional, defaults to true
100101
mustHaveBlankDayField: false, // optional, default to false
101102
useLastDayOfMonth: false, // optional, default to false
102103
useLastDayOfWeek: false, // optional, default to false
@@ -161,6 +162,9 @@ The preset properties explained:
161162
- enables blank day notation '?' in daysOfMonth and daysOfWeek field
162163
- `allowOnlyOneBlankDayField: boolean`
163164
- requires a day field to not be blank (so not both day fields can be blank)
165+
- `allowStepping: boolean`
166+
- optional, will default to true
167+
- when set to false, disallows the use of the '/' operation for valid expressions
164168
- `mustHaveBlankDayField: boolean`
165169
- requires a day field to be blank (so not both day fields are specified)
166170
- when mixed with `allowOnlyOneBlankDayField`, it means that there will always be either day or day of week as `?`
@@ -200,14 +204,14 @@ If you want to override a option for single cron validations, you can use the `o
200204

201205
```typescript
202206
console.log(cron('* * * * * *', {
203-
preset: 'default' // second field not supported in default preset
207+
preset: 'default', // second field not supported in default preset
204208
override: {
205209
useSeconds: true // override preset option
206210
}
207211
}))
208212

209213
console.log(cron('* 10-20 * * * *', {
210-
preset: 'default'
214+
preset: 'default',
211215
override: {
212216
minutes: {
213217
lowerLimit: 10, // override preset option

src/helper.ts

+4
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ const checkListElement = (
255255
)
256256
}
257257

258+
if (!options.allowStepping) {
259+
return err('Stepping (\'/\') is now allowed.')
260+
}
261+
258262
const firstElementResult = checkFirstStepElement(
259263
stepArray[0],
260264
cronFieldType,

0 commit comments

Comments
 (0)