mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-02 02:50:16 +01:00
make validations a bit more dry
This commit is contained in:
parent
29b815e998
commit
bad91e8d10
4 changed files with 23 additions and 16 deletions
|
|
@ -40,12 +40,13 @@ module RecurringTodos
|
|||
|
||||
def validate
|
||||
super
|
||||
|
||||
case recurrence_selector
|
||||
when 0 # 'monthly_every_x_day'
|
||||
errors[:base] << "Every other nth month may not be empty for recurrence setting" if every_x_month.blank?
|
||||
validate_not_blank(every_x_month, "Every other nth month may not be empty for recurrence setting")
|
||||
when 1 # 'every_xth_day'
|
||||
errors[:base] <<"Every other nth month may not be empty for recurrence setting" if every_x_month2.blank?
|
||||
errors[:base] <<"The day of the month may not be empty for recurrence setting" if day_of_week.blank?
|
||||
validate_not_blank(every_x_month2, "Every other nth month may not be empty for recurrence setting")
|
||||
validate_not_blank(day_of_week, "The day of the month may not be empty for recurrence setting")
|
||||
else
|
||||
raise Exception.new, "unexpected value of recurrence selector '#{recurrence_selector}'"
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue