Add exhaustive patterns to FromJSON Role instance

When someone enters something like role=mgr, return a helpful error message to
the user.

Note: I should enable the exhaustive patterns check for GHC.
This commit is contained in:
William Carroll 2020-08-01 11:46:41 +01:00
parent 9666d5dce1
commit a3732300e1

View file

@ -114,6 +114,7 @@ instance FromJSON Role where
"user" -> pure RegularUser
"manager" -> pure Manager
"admin" -> pure Admin
_ -> fail "Expected \"user\" or \"manager\" or \"admin\""
instance ToField Role where
toField RegularUser = SQLText "user"