lib/codebreaker_kirill/validations.rb in codebreaker_kirill-0.2.15 vs lib/codebreaker_kirill/validations.rb in codebreaker_kirill-0.2.16
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
module Validations
def 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
@@ -12,8 +14,10 @@
raise 'Name shouldn\'t be more than 4 characters long' if guess.length > 4
end
def validate_difficulty(difficulty)
raise "Input shouldn't be empty" if difficulty.empty?
- raise 'You should enter one of the following options: easy, medium, hell' unless difficulty.match?(/easy|medium|hell/)
+ return if difficulty.match?(/easy|medium|hell/)
+
+ raise 'You should enter one of the following options: easy, medium, hell'
end
end