From 88707277ec00b944cbaa1ecb2896cf4c8c017369 Mon Sep 17 00:00:00 2001 From: brensch Date: Wed, 9 Mar 2022 23:26:20 -0800 Subject: [PATCH] fix #77: checking through all words to make sure word is actually a word --- validation.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/validation.go b/validation.go index c4a2eca..e7464d6 100644 --- a/validation.go +++ b/validation.go @@ -8,7 +8,22 @@ const ( // TODO: get word list up in here func ValidGuess(guess, answer string) bool { - return len(guess) == len(answer) + if len(guess) != len(answer) { + return false + } + + for _, validWord := range CommonWords { + if validWord == guess { + return true + } + } + + for _, validWord := range AllWords { + if validWord == guess { + return true + } + } + return false } func GetResult(guess, answer string) GuessResult {