Details
-
Task
-
Status: Open
-
Normal
-
Resolution: Unresolved
-
None
-
None
-
Windows
-
1
-
Needs Assessment
Description
Logic in the canonicalize_and_validate method takes a number of unique code paths specific to individual trigger types. It may be more useful to define some Ruby hashes that contain a "schema", so that validation logic could be more normalized / handled generically.
So for instance, something like
# base ITrigger
|
trigger_defaults => {
|
fields => {
|
'schedule' => { type => String, values => 'daily, weekly, monthly, once', required => true }, |
'start_time' => { type => String, pattern => '\d\d:\d\d', required => true }, |
'start_date' => { type => String }, |
'minutes_interval' => { type => Integer }, |
'minutes_duration' => { type => Integer }, |
}
|
}
|
daily_trigger => {
|
type => 2, |
fields => {
|
'every' => { type => Numeric, values => [1, 2] }, |
# etc |
}
|
}
|
monthly_trigger => {
|
type => 4, |
fields => {
|
'which_occurrence' => { type => Array, values => ['first', 'second', 'third', 'fourth', 'last'] } |
# etc |
}
|
}
|
I won't model them all out, but that should set the gist of things.
A full breakdown of all allowed values is in
https://gist.github.com/Iristyle/58ff446bd3f60e68d52df3868c917a0e
This is also likely the best way to fix the bug where mutually exclusive trigger hash settings are currently ignored. For example, a schedule of 'once' will accept an every value of '1', even though its unused, and there a number of other such examples.