Module: Config::DryValidationRequirements

Defined in:
lib/config/dry_validation_requirements.rb

Constant Summary collapse

VERSIONS =
['~> 1.0', '>= 1.0.0'].freeze

Class Method Summary collapse

Class Method Details

.load_dry_validation!Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/config/dry_validation_requirements.rb', line 7

def self.load_dry_validation!
  return if defined?(@load_dry_validation)

  begin
    require 'dry/validation/version'
    version = Gem::Version.new(Dry::Validation::VERSION)
    unless VERSIONS.all? { |req| Gem::Requirement.new(req).satisfied_by?(version) }
      raise LoadError
    end
  rescue LoadError
    raise ::Config::Error, 'Could not find a dry-validation version' \
      ' matching requirements' \
      " (#{VERSIONS.map(&:inspect) * ','})"
  end

  require 'dry/validation'
  @load_dry_validation = true
  nil
end