diff --git a/src/Password.hs b/src/Password.hs index 3fbeb5b..4437f20 100644 --- a/src/Password.hs +++ b/src/Password.hs @@ -69,13 +69,10 @@ newPWPolicy = PWPolicy 16 0 0 0 (Just 0) validatePWPolicy :: PWPolicy -- ^ the policy being validated - -> Maybe PWPolicy - -- ^ the policy if it is valid, or @"Nothing"@ if it is not -validatePWPolicy x = if needed <= x^.pwLength - then Just x - else Nothing - where - needed = x^.pwUpper + x^.pwLower + x^.pwDigits + special - special = fromMaybe 0 $ x^.pwSpecial + -> Bool + -- ^ indicates whether or not the policy is valid +validatePWPolicy x = needed <= x^.pwLength where + needed = x^.pwUpper + x^.pwLower + x^.pwDigits + special + special = fromMaybe 0 $ x^.pwSpecial --jl diff --git a/test/Spec/ValidatePWPolicy.hs b/test/Spec/ValidatePWPolicy.hs index e33ff56..1213c73 100644 --- a/test/Spec/ValidatePWPolicy.hs +++ b/test/Spec/ValidatePWPolicy.hs @@ -40,8 +40,8 @@ tests = TestLabel "validatePWPolicy" $ TestList $ map test' , ( "short invalid", shortInvalid, False ) ] -test' (label, f, valid) = TestLabel label $ - validatePWPolicy x ~?= if valid then Just x else Nothing where +test' (label, f, expect) = TestLabel label $ + validatePWPolicy x ~?= expect where x = f newPWPolicy validMins = setAll 1