Sha256: e7aa9038473ce1524946db79c9ab3c9bc6b4e8e69c1c5a0124be94a1107ddf85

Contents?: true

Size: 1.07 KB

Versions: 9

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

# @api private
# @since 0.13.0
class Qonfig::Validator
  require_relative 'validator/basic'
  require_relative 'validator/method_based'
  require_relative 'validator/proc_based'
  require_relative 'validator/builder'
  require_relative 'validator/collection'
  require_relative 'validator/predefined'
  require_relative 'validator/dsl'

  # @param data_set [Qonfig::DataSet]
  # @return [void]
  #
  # @api private
  # @since 0.13.0
  def initialize(data_set)
    @data_set = data_set
    @validators = data_set.class.validators.dup
  end

  # @return [void]
  #
  # @api private
  # @since 0.13.0
  def validate!
    validators.each do |validator|
      validator.validate(data_set)
    end
  end

  # @return [Boolean]
  #
  # @api private
  # @since 0.13.0
  def valid?
    validate!
    true
  rescue Qonfig::ValidationError
    false
  end

  private

  # @return [Qonfig::DataSet]
  #
  # @api private
  # @since 0.13.0
  attr_reader :data_set

  # @return [Qonfig::Validator::Collection]
  #
  # @api private
  # @since 0.13.0
  attr_reader :validators
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
qonfig-0.19.1 lib/qonfig/validator.rb
qonfig-0.19.0 lib/qonfig/validator.rb
qonfig-0.18.1 lib/qonfig/validator.rb
qonfig-0.18.0 lib/qonfig/validator.rb
qonfig-0.17.0 lib/qonfig/validator.rb
qonfig-0.16.0 lib/qonfig/validator.rb
qonfig-0.15.0 lib/qonfig/validator.rb
qonfig-0.14.0 lib/qonfig/validator.rb
qonfig-0.13.0 lib/qonfig/validator.rb