Class: Yard::Lint::ConfigValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/yard/lint/config_validator.rb

Overview

Validates configuration structure and values to catch typos and invalid settings

Constant Summary collapse

VALID_CATEGORIES =

Valid category names (from ConfigUpdater::CATEGORY_ORDER)

%w[Documentation Tags Warnings Semantic].freeze
SPECIAL_KEYS =

Keys that are valid at the root level but are not validators

%w[
  AllValidators
  inherit_from
  inherit_gem
].freeze
BOOLEAN_VALUES =

Valid boolean values

[true, false].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_config) ⇒ ConfigValidator

Returns a new instance of ConfigValidator.

Parameters:

  • raw_config (Hash)

    raw configuration hash to validate



23
24
25
26
# File 'lib/yard/lint/config_validator.rb', line 23

def initialize(raw_config)
  @raw_config = raw_config
  @errors = []
end

Class Method Details

.validate!(raw_config) ⇒ void

This method returns an undefined value.

Validate configuration and raise error if invalid

Parameters:

  • raw_config (Hash)

    raw configuration hash to validate

Raises:



32
33
34
35
# File 'lib/yard/lint/config_validator.rb', line 32

def self.validate!(raw_config)
  validator = new(raw_config)
  validator.validate!
end

Instance Method Details

#validate!void

This method returns an undefined value.

Perform validation

Raises:



40
41
42
43
44
45
46
47
48
# File 'lib/yard/lint/config_validator.rb', line 40

def validate!
  validate_root_keys!
  validate_global_settings!
  validate_validators!

  return if @errors.empty?

  raise Errors::InvalidConfigError, build_error_message
end