98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/huginn_openweathermap_agent/openweathermap_agent.rb', line 98
def validate_options
errors.add(:base, "type has invalid value: should be 'current_weather' 'air_pollution' 'onecall' 'forecast5d'") if interpolated['type'].present? && !%w(current_weather air_pollution onecall forecast5d).include?(interpolated['type'])
errors.add(:base, "unit has invalid value: should be 'metric' 'standard' 'imperial'") if interpolated['type'].present? && !%w(metric standard imperial).include?(interpolated['unit'])
errors.add(:base, "lon must be provided") if not interpolated['lon'].present? && ( interpolated['type'] == 'current_weather' or interpolated['type'] == 'air_pollution' or interpolated['type'] == 'onecall' or interpolated['type'] == 'forecast5d')
errors.add(:base, "lat must be provided") if not interpolated['lat'].present? && ( interpolated['type'] == 'current_weather' or interpolated['type'] == 'air_pollution' or interpolated['type'] == 'onecall' or interpolated['type'] == 'forecast5d')
unless options['language'].present?
errors.add(:base, "language is a required field")
end
unless options['token'].present?
errors.add(:base, "token is a required field")
end
if options.has_key?('emit_events') && boolify(options['emit_events']).nil?
errors.add(:base, "if provided, emit_events 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
|