Sha256: 543ae49d35f00d30242176deab29c8a9c1dfdc1375a9351d07bf4f5ba5657c77

Contents?: true

Size: 579 Bytes

Versions: 6

Compression:

Stored size: 579 Bytes

Contents

# frozen_string_literal: true

# Main Gem module
module CodeBrkrGameTraining
  # Data validation module
  module Validator
    DataValidError = Class.new(StandardError)

    def check_type(data, check_type)
      raise DataValidError, 'unexpected_type' unless data.instance_of? check_type
    end

    def check_length(data, check)
      raise DataValidError, 'unexpected_length' unless (check[:min]..check[:max]).cover? data.length
    end

    def check_contain_hash_key(val, hash)
      raise DataValidError, 'hash_key_not_found' unless hash.key? val.to_sym
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
code_brkr_game_training-0.9.2 lib/code_brkr_game_training/modules/validator.rb
code_brkr_game_training-0.9.1 lib/code_brkr_game_training/modules/validator.rb
code_brkr_game_training-0.8.5 lib/code_brkr_game_training/modules/validator.rb
code_brkr_game_training-0.8.0 lib/code_brkr_game_training/modules/validator.rb
code_brkr_game_training-0.7.5 lib/code_brkr_game_training/modules/validator.rb
code_brkr_game_training-0.7.2 lib/code_brkr_game_training/modules/validator.rb