checkMMod

This commit is contained in:
Michael Snoyman 2012-08-22 20:05:34 +03:00
parent 34db07760a
commit 6b31b583f2
2 changed files with 15 additions and 8 deletions

View File

@ -33,6 +33,7 @@ module Yesod.Form.Functions
, check
, checkBool
, checkM
, checkMMod
, customErrorMessage
-- * Utilities
, fieldSettingsLabel
@ -355,14 +356,20 @@ checkM :: RenderMessage master msg
=> (a -> GHandler sub master (Either msg a))
-> Field sub master a
-> Field sub master a
checkM f = checkM' f id
checkM f = checkMMod 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
-- | Same as 'checkM', but modifies the datatype.
--
-- 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).
--
-- 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 f inv field = field
{ fieldParse = \ts -> do
e1 <- fieldParse field ts
case e1 of

View File

@ -1,5 +1,5 @@
name: yesod-form
version: 1.1.0.1
version: 1.1.1
license: MIT
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>