Sha256: d78ed890aa707b8ced6d7d5299beea370f5b2db6018ed4ef2a0bf4a28c453832

Contents?: true

Size: 835 Bytes

Versions: 1

Compression:

Stored size: 835 Bytes

Contents

# frozen_string_literal: true

class Validations
  def self.validate_name(name)
    raise "Name shouldn't be empty" if name.empty?
    raise 'Name should be string' if name.class != String
    raise 'Name should be at least 3 characters long' if name.length < 3
    raise "Name shouldn't be more than 20 characters long" if name.length > 20
  end

  def self.validate_guess(guess)
    raise "Name shouldn't be empty" if guess.empty?
    raise 'Name should be at least 3 characters long' if guess.length < 4
    raise 'Name shouldn\'t be more than 4 characters long' if guess.length > 4
  end

  def self.validate_difficulty(difficulty)
    raise "Input shouldn't be empty" if difficulty.empty?
    return if difficulty.match?(/easy|medium|hell/)

    raise 'You should enter one of the following options: easy, medium, hell'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
codebreaker_kirill-0.2.19 lib/codebreaker_kirill/validations.rb