Method: RubyJard::ControlFlow#validate!

Defined in:
lib/ruby_jard/control_flow.rb

#validate!Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ruby_jard/control_flow.rb', line 31

def validate!
  if command.to_s.empty?
    raise RubyJard::Error, 'Control command is empty'
  end

  unless ALLOW_LIST.key?(command)
    raise RubyJard::Error,
          "Control command `#{command}` is not registered in the allow list."
  end

  invalid_keys = arguments.keys - ALLOW_LIST[command]
  unless invalid_keys.empty?
    raise RubyJard::Error,
          "Control command `#{command}` is attached with unregister arguments: #{invalid_keys}"
  end
end