Skip to content

Commit

Permalink
feat: add two additional option presets
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin committed Apr 15, 2020
1 parent 2f6290e commit 489e472
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/option.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as yup from 'yup'
import type { ValidationError } from 'yup'
import { err, valid } from './result'
import presets from './presets'

interface OptionPreset {
presetId: string
Expand Down Expand Up @@ -203,6 +204,9 @@ export interface InputOptions {

export const validateOptions = (inputOptions: InputOptions) => {
try {
// load default presets
presets()

let preset: OptionPreset
if (inputOptions.preset) {
if (typeof inputOptions.preset === 'string') {
Expand Down
73 changes: 73 additions & 0 deletions src/presets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { registerOptionPreset } from './option'

export default () => {
registerOptionPreset('npm-node-cron', {
// https://github.com/kelektiv/node-cron
presetId: 'npm-node-cron',
useSeconds: true,
useYears: false,
seconds: {
minValue: 0,
maxValue: 59,
},
minutes: {
minValue: 0,
maxValue: 59,
},
hours: {
minValue: 0,
maxValue: 23,
},
daysOfMonth: {
minValue: 1,
maxValue: 31,
},
months: {
minValue: 0,
maxValue: 11,
},
daysOfWeek: {
minValue: 0,
maxValue: 6,
},
years: {
minValue: 1970,
maxValue: 2099,
},
})

registerOptionPreset('aws', {
// https://docs.aws.amazon.com/de_de/AmazonCloudWatch/latest/events/ScheduledEvents.html
presetId: 'aws',
useSeconds: false,
useYears: true,
seconds: {
minValue: 0,
maxValue: 59,
},
minutes: {
minValue: 0,
maxValue: 59,
},
hours: {
minValue: 0,
maxValue: 23,
},
daysOfMonth: {
minValue: 1,
maxValue: 31,
},
months: {
minValue: 0,
maxValue: 12,
},
daysOfWeek: {
minValue: 1,
maxValue: 7,
},
years: {
minValue: 1970,
maxValue: 2199,
},
})
}

0 comments on commit 489e472

Please sign in to comment.