# frozen_string_literal: true require_relative 'game' module Codebreaker class User < BaseClass attr_accessor :errors attr_reader :name def initialize(player_name) @errors = [] validation_name(player_name) @errors.empty? ? @name = player_name : show_errors super() end def validation_name(player_name) if player_name.is_a?(String) @errors << 'error min length or max length' unless Constants::LENGTH_RANGE.include?(player_name.length) else @errors << 'name is not string' end end end end