Method: PuppetX::EasyType::Validation::CheckImplementation#not_allowed

Defined in:
lib/puppet_x/easy_type/validation/check_implementation.rb

#not_allowed(output) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/puppet_x/easy_type/validation/check_implementation.rb', line 71

def not_allowed(output)
  return true if resource[:not_allowed_output].nil?

  not_allowed_outputs = Array(resource[:not_allowed_output])
  not_allowed_outputs.all? do | not_allowed|
    if not_allowed.is_a? Regexp
      if output.match?(not_allowed)
        Puppet.debug "Regular expression '#{not_allowed}' found in output."
        return false
      else
        Puppet.debug "Regular expression '#{not_allowed}' NOT found in output."
        return true
      end
    else
      if output == not_allowed
        Puppet.debug "String '#{not_allowed}' found in output."
        return true
      else
        Puppet.debug "String '#{not_allowed}' NOT found in output."
        return false
      end
    end
  end
end