checkM' (need to rename it)
This commit is contained in:
parent
d465d30863
commit
a5361e44f2
@ -338,13 +338,21 @@ checkM :: RenderMessage master msg
|
|||||||
=> (a -> GHandler sub master (Either msg a))
|
=> (a -> GHandler sub master (Either msg a))
|
||||||
-> Field sub master a
|
-> Field sub master a
|
||||||
-> Field sub master a
|
-> Field sub master a
|
||||||
checkM f field = field
|
checkM f = checkM' f id
|
||||||
|
|
||||||
|
checkM' :: RenderMessage master msg
|
||||||
|
=> (a -> GHandler sub master (Either msg b))
|
||||||
|
-> (b -> a)
|
||||||
|
-> Field sub master a
|
||||||
|
-> Field sub master b
|
||||||
|
checkM' f inv field = field
|
||||||
{ fieldParse = \ts -> do
|
{ fieldParse = \ts -> do
|
||||||
e1 <- fieldParse field ts
|
e1 <- fieldParse field ts
|
||||||
case e1 of
|
case e1 of
|
||||||
Left msg -> return $ Left msg
|
Left msg -> return $ Left msg
|
||||||
Right Nothing -> return $ Right Nothing
|
Right Nothing -> return $ Right Nothing
|
||||||
Right (Just a) -> fmap (either (Left . SomeMessage) (Right . Just)) $ f a
|
Right (Just a) -> fmap (either (Left . SomeMessage) (Right . Just)) $ f a
|
||||||
|
, fieldView = \i n a eres req -> fieldView field i n a (fmap inv eres) req
|
||||||
}
|
}
|
||||||
|
|
||||||
-- | Allows you to overwrite the error message on parse error.
|
-- | Allows you to overwrite the error message on parse error.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user