class Goliath::Rack::Validation::RequiredParam
def key_valid?(params)
def key_valid?(params) key_path = Array(@key) current_value = params # check that the full path is present # omit the last part of the path key_path[0...-1].each do |key_part| # if the key is missing or is nil the validation failed if !current_value.is_a?(Hash) || current_value[key_part].nil? return false end current_value = current_value[key_part] end # if we are here the full path is available, now test the real key val = current_value[key_path[-1]] case val when nil return false when String # if val is a string it must not be empty return false if val !~ NON_WHITESPACE_REGEXP when Array unless val.compact.empty? val.each do |k| return true unless k.is_a?(String) return true unless k !~ NON_WHITESPACE_REGEXP end end return false end true end