Class: Monerorequest::Validator::StartDate

Inherits:
Object
  • Object
show all
Defined in:
lib/monerorequest/validator/start_date.rb

Overview

validates the start_date field

Class Method Summary collapse

Class Method Details

.validate!(data) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/monerorequest/validator/start_date.rb', line 9

def self.validate!(data)
  errors = []
  errors.push("start_date must be present.") unless data.key?("start_date")
  errors.push("start_date must be a String.") && data["start_date"] = "" unless data["start_date"].is_a?(String)
  begin
    DateTime.rfc3339(data["start_date"])
  rescue Date::Error
    errors.push("start_date must be an RFC3339 timestamp.")
  end
  errors
end