made validatePWPolicy return Bool
This commit is contained in:
parent
3a92469554
commit
36e2ac9883
|
@ -69,13 +69,10 @@ newPWPolicy = PWPolicy 16 0 0 0 (Just 0)
|
||||||
validatePWPolicy
|
validatePWPolicy
|
||||||
:: PWPolicy
|
:: PWPolicy
|
||||||
-- ^ the policy being validated
|
-- ^ the policy being validated
|
||||||
-> Maybe PWPolicy
|
-> Bool
|
||||||
-- ^ the policy if it is valid, or @"Nothing"@ if it is not
|
-- ^ indicates whether or not the policy is valid
|
||||||
validatePWPolicy x = if needed <= x^.pwLength
|
validatePWPolicy x = needed <= x^.pwLength where
|
||||||
then Just x
|
needed = x^.pwUpper + x^.pwLower + x^.pwDigits + special
|
||||||
else Nothing
|
special = fromMaybe 0 $ x^.pwSpecial
|
||||||
where
|
|
||||||
needed = x^.pwUpper + x^.pwLower + x^.pwDigits + special
|
|
||||||
special = fromMaybe 0 $ x^.pwSpecial
|
|
||||||
|
|
||||||
--jl
|
--jl
|
||||||
|
|
|
@ -40,8 +40,8 @@ tests = TestLabel "validatePWPolicy" $ TestList $ map test'
|
||||||
, ( "short invalid", shortInvalid, False )
|
, ( "short invalid", shortInvalid, False )
|
||||||
]
|
]
|
||||||
|
|
||||||
test' (label, f, valid) = TestLabel label $
|
test' (label, f, expect) = TestLabel label $
|
||||||
validatePWPolicy x ~?= if valid then Just x else Nothing where
|
validatePWPolicy x ~?= expect where
|
||||||
x = f newPWPolicy
|
x = f newPWPolicy
|
||||||
|
|
||||||
validMins = setAll 1
|
validMins = setAll 1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user