Class: Longleaf::StorageLocationValidator
- Inherits:
-
ConfigurationValidator
- Object
- ConfigurationValidator
- Longleaf::StorageLocationValidator
- Defined in:
- lib/longleaf/services/storage_location_validator.rb
Overview
Validates application configuration of storage locations
Class Method Summary collapse
-
.validate_config(config) ⇒ Object
Validates configuration to ensure that it is syntactically correct and does not violate schema and uniqueness requirements.
Class Method Details
.validate_config(config) ⇒ Object
Validates configuration to ensure that it is syntactically correct and does not violate schema and uniqueness requirements.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/longleaf/services/storage_location_validator.rb', line 16 def self.validate_config(config) assert("Configuration must be a hash, but a #{config.class} was provided", config.class == Hash) assert("Configuration must contain a root '#{AF::LOCATIONS}' key", config.key?(AF::LOCATIONS)) locations = config[AF::LOCATIONS] assert("'#{AF::LOCATIONS}' must be a hash of locations", locations.class == Hash) existing_paths = Array.new locations.each do |name, properties| assert("Name of storage location must be a string, but was of type #{name.class}", name.instance_of?(String)) assert("Storage location '#{name}' must be a hash, but a #{properties.class} was provided", properties.is_a?(Hash)) assert_path_property_valid(name, AF::LOCATION_PATH, properties, existing_paths) assert_path_property_valid(name, AF::METADATA_PATH, properties, existing_paths) end end |