Method: Vagrant::Config::Top#validate!

Defined in:
lib/vagrant/config/top.rb

#validate!(env) ⇒ Object

Validates the configuration classes of this instance and raises an exception if they are invalid. If you are implementing a custom configuration class, the method you want to implement is Base#validate. This is the method that checks all the validation, not one which defines validation rules.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/vagrant/config/top.rb', line 56

def validate!(env)
  # Validate each of the configured classes and store the results into
  # a hash.
  errors = @keys.inject({}) do |container, data|
    key, instance = data
    recorder = ErrorRecorder.new
    instance.validate(env, recorder)
    container[key.to_sym] = recorder if !recorder.errors.empty?
    container
  end

  return if errors.empty?
  raise Errors::ConfigValidationFailed, :messages => Util::TemplateRenderer.render("config/validation_failed", :errors => errors)
end