96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/openc3/models/trigger_model.rb', line 96
def validate_operand(operand:)
unless operand.is_a?(Hash)
raise TriggerInputError.new "invalid operand: #{operand}"
end
operand_types = [ITEM_TYPE, LIMIT_TYPE, FLOAT_TYPE, STRING_TYPE, TRIGGER_TYPE]
unless operand_types.include?(operand['type'])
raise TriggerInputError.new "invalid operand type: #{operand['type']} must be of type: #{operand_types}"
end
if operand[operand['type']].nil?
raise TriggerInputError.new "invalid operand must contain type: #{operand}"
end
case operand['type']
when ITEM_TYPE
if operand['target'].nil? || operand['packet'].nil? || operand['raw'].nil?
raise TriggerInputError.new "invalid operand must contain target, packet, item, and raw: #{operand}"
end
when TRIGGER_TYPE
@roots << operand[operand['type']]
end
return operand
end
|