Skip to content

Commit 888bfa9

Browse files
authored
feat: add npm-cron-schedule preset (#124)
1 parent e393a1c commit 888bfa9

File tree

2 files changed

+45
-9
lines changed

2 files changed

+45
-9
lines changed

README.md

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,13 @@ The following presets are already defined by cron-validate:
7474
- default (see: http://crontab.org/)
7575
- npm-node-cron (see: https://github.com/kelektiv/node-cron)
7676
- aws-cloud-watch (see: https://docs.aws.amazon.com/de_de/AmazonCloudWatch/latest/events/ScheduledEvents.html)
77+
- npm-cron-schedule (see: https://github.com/P4sca1/cron-schedule)
7778

7879
To select a preset for your validation, you can simply do this:
7980

8081
```typescript
8182
cron('* * * * *', {
82-
preset: 'npm-node-cron',
83-
})
84-
```
85-
86-
or
87-
88-
```typescript
89-
cron('* * * * *', {
90-
preset: 'aws-cloud-watch',
83+
preset: 'npm-cron-schedule',
9184
})
9285
```
9386

src/presets.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,47 @@ export default (): void => {
8686
maxValue: 2199,
8787
},
8888
})
89+
90+
registerOptionPreset('npm-cron-schedule', {
91+
// https://github.com/P4sca1/cron-schedule
92+
presetId: 'npm-cron-schedule',
93+
useSeconds: true,
94+
useYears: false,
95+
useAliases: true,
96+
useBlankDay: false,
97+
allowOnlyOneBlankDayField: false,
98+
mustHaveBlankDayField: false,
99+
useLastDayOfMonth: false,
100+
useLastDayOfWeek: false,
101+
useNearestWeekday: false,
102+
useNthWeekdayOfMonth: false,
103+
seconds: {
104+
minValue: 0,
105+
maxValue: 59,
106+
},
107+
minutes: {
108+
minValue: 0,
109+
maxValue: 59,
110+
},
111+
hours: {
112+
minValue: 0,
113+
maxValue: 23,
114+
},
115+
daysOfMonth: {
116+
minValue: 1,
117+
maxValue: 31,
118+
},
119+
months: {
120+
minValue: 1,
121+
maxValue: 12,
122+
},
123+
daysOfWeek: {
124+
minValue: 0,
125+
maxValue: 7,
126+
},
127+
years: {
128+
minValue: 1970,
129+
maxValue: 2099,
130+
},
131+
})
89132
}

0 commit comments

Comments
 (0)