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:
parent
9666d5dce1
commit
a3732300e1
1 changed files with 1 additions and 0 deletions
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue