Method: Puppet::Type.validate

Defined in:
lib/puppet/type.rb

.validate {|| ... } ⇒ void

This method returns an undefined value.

Creates a ‘validate` method that is used to validate a resource before it is operated on. The validation should raise exceptions if the validation finds errors. (It is not recommended to issue warnings as this typically just ends up in a logfile - you should fail if a validation fails). The easiest way to raise an appropriate exception is to call the method Util::Errors.fail with the message as an argument.

Yields:

  • ()

    a required block called with self set to the instance of a Type class representing a resource.



2294
2295
2296
2297
2298
2299
2300
2301
2302
# File 'lib/puppet/type.rb', line 2294

def self.validate(&block)
  define_method(:unsafe_validate, &block)

  define_method(:validate) do
    return if enum_for(:eachparameter).any? { |p| p.value.instance_of?(Puppet::Pops::Evaluator::DeferredValue) }

    unsafe_validate
  end
end