Method: Snapi::Function#valid_args?

Defined in:
lib/snapi/function.rb

#valid_args?(args = {}) ⇒ Boolean

This method accepts a hash (as from a web request) which it uses to compare against its argument definitions in order to do some upfront validation before trying to run the function names as defined in the library_class

TODO: build up an errors hash to disclose what the issue is

Returns:



62
63
64
65
66
67
68
69
70
71
# File 'lib/snapi/function.rb', line 62

def valid_args?(args={})
  valid = false
  arguments.each do |name, argument|
    if argument[:required]
      return false if args[name] == nil
    end
    valid =  argument.valid_input?(args[name])
  end
  return valid
end