checkMMod to checkMMap (#416)
This commit is contained in:
parent
4cce1d5a8f
commit
498d22714b
@ -33,6 +33,7 @@ module Yesod.Form.Functions
|
|||||||
, check
|
, check
|
||||||
, checkBool
|
, checkBool
|
||||||
, checkM
|
, checkM
|
||||||
|
, checkMMap
|
||||||
, checkMMod
|
, checkMMod
|
||||||
, customErrorMessage
|
, customErrorMessage
|
||||||
-- * Utilities
|
-- * Utilities
|
||||||
@ -356,20 +357,20 @@ 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 = checkMMod f id
|
checkM f = checkMMap f id
|
||||||
|
|
||||||
-- | Same as 'checkM', but modifies the datatype.
|
-- | Same as 'checkM', but modifies the datatype.
|
||||||
--
|
--
|
||||||
-- In order to make this work, you must provide a function to convert back from
|
-- In order to make this work, you must provide a function to convert back from
|
||||||
-- the new datatype to the old one (the second argument to this function).
|
-- the new datatype to the old one (the second argument to this function).
|
||||||
--
|
--
|
||||||
-- Since 1.1.1
|
-- Since 1.1.2
|
||||||
checkMMod :: RenderMessage master msg
|
checkMMap :: RenderMessage master msg
|
||||||
=> (a -> GHandler sub master (Either msg b))
|
=> (a -> GHandler sub master (Either msg b))
|
||||||
-> (b -> a)
|
-> (b -> a)
|
||||||
-> Field sub master a
|
-> Field sub master a
|
||||||
-> Field sub master b
|
-> Field sub master b
|
||||||
checkMMod f inv field = field
|
checkMMap f inv field = field
|
||||||
{ fieldParse = \ts -> do
|
{ fieldParse = \ts -> do
|
||||||
e1 <- fieldParse field ts
|
e1 <- fieldParse field ts
|
||||||
case e1 of
|
case e1 of
|
||||||
@ -379,6 +380,17 @@ checkMMod f inv field = field
|
|||||||
, fieldView = \i n a eres req -> fieldView field i n a (fmap inv eres) req
|
, fieldView = \i n a eres req -> fieldView field i n a (fmap inv eres) req
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- | Deprecated synonym for 'checkMMap'.
|
||||||
|
--
|
||||||
|
-- Since 1.1.1
|
||||||
|
checkMMod :: RenderMessage master msg
|
||||||
|
=> (a -> GHandler sub master (Either msg b))
|
||||||
|
-> (b -> a)
|
||||||
|
-> Field sub master a
|
||||||
|
-> Field sub master b
|
||||||
|
checkMMod = checkMMap
|
||||||
|
{-# DEPRECATED checkMMod "Please use checkMMap instead" #-}
|
||||||
|
|
||||||
-- | Allows you to overwrite the error message on parse error.
|
-- | Allows you to overwrite the error message on parse error.
|
||||||
customErrorMessage :: SomeMessage master -> Field sub master a -> Field sub master a
|
customErrorMessage :: SomeMessage master -> Field sub master a -> Field sub master a
|
||||||
customErrorMessage msg field = field { fieldParse = \ts -> fmap (either
|
customErrorMessage msg field = field { fieldParse = \ts -> fmap (either
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user