Module: TaskWarrior::Validations

Included in:
Annotation, Task
Defined in:
lib/taskwarrior/validations.rb

Instance Method Summary collapse

Instance Method Details

#entry_cannot_be_in_the_futureObject



10
11
12
13
14
15
16
17
18
# File 'lib/taskwarrior/validations.rb', line 10

def entry_cannot_be_in_the_future
  begin
    if !entry.blank? and entry > DateTime.now
      errors.add(:entry, "can't be in the future")
    end
  rescue
    errors.add(:entry, "must be comparable to DateTime")
  end
end

#must_be_date_or_nil(sym) ⇒ Object



3
4
5
6
7
8
# File 'lib/taskwarrior/validations.rb', line 3

def must_be_date_or_nil(sym)
  datish = self.send(sym)
  if !(datish.nil? or datish.is_a?(DateTime))
    errors.add(sym, "must be nil or a valid DateTime object")
  end
end