277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
|
# File 'lib/huginn_transilien_agent/transilien_agent.rb', line 277
def validate_options
errors.add(:base, "type has invalid value: should be 'itinary' 'nextdeparture' 'traffic_reports'") if interpolated['type'].present? && !%w(itinary nextdeparture traffic_reports).include?(interpolated['type'])
unless options['src'].present? || !['itinary', 'nextdeparture'].include?(options['type'])
errors.add(:base, "src is a required field")
end
unless options['dst'].present? || !['itinary', 'nextdeparture'].include?(options['type'])
errors.add(:base, "dst is a required field")
end
unless options['token'].present? || !['itinary', 'nextdeparture', 'traffic_reports'].include?(options['type'])
errors.add(:base, "token is a required field")
end
if options.has_key?('changes_only') && boolify(options['changes_only']).nil?
errors.add(:base, "if provided, changes_only must be true or false")
end
if options.has_key?('debug') && boolify(options['debug']).nil?
errors.add(:base, "if provided, debug must be true or false")
end
unless options['expected_receive_period_in_days'].present? && options['expected_receive_period_in_days'].to_i > 0
errors.add(:base, "Please provide 'expected_receive_period_in_days' to indicate how many days can pass before this Agent is considered to be not working")
end
end
|