Sha256: ad8c924aac1e85e2604b61f75b55fdc57f7eda86cc8bcdef7ca25f4e6bf3d41b

Contents?: true

Size: 531 Bytes

Versions: 1

Compression:

Stored size: 531 Bytes

Contents

# frozen_string_literal: true

require_relative "errors/input_error"
require_relative "errors/length_error"
require_relative "errors/state_error"

module Codebreaker
  module Validation
    NUMBERS = /^[1-6]{4}$/

    def validate_name(name)
      raise LengthError unless Constants::NAME_LENGTH.cover?(name.length)
    end

    def validate_guess(code)
      raise InputError unless  NUMBERS.match?(code)
    end

    def validate_state(state, current_state)
      raise StateError unless state == current_state
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
codebreaker-mikhail-0.1.2 lib/codebreaker/validation/validation.rb