【发布时间】:2016-01-15 22:39:44
【问题描述】:
假设我们有这样的东西:
myForm :: Form (Text, Text)
myForm = renderBootstrap3 BootstrapBasicForm $ (,)
<$> areq passwordField (bfs ("Password" :: Text)) Nothing
<*> areq passwordField (bfs ("Repeat password" :: Text)) Nothing
是否可以检查两个字段是否相同?验证是
描述here,
check
似乎不够强大,无法执行这种检查。也许
checkM
可能有用吗?
如果无法使用内置 Yesod 设施,那将是什么 最好的解决方法?我能想到:
postSomethingR :: Handler Html
postSomethingR = do
((result, form), enctype) <- runFormPost myForm
case result of
FormSuccess (password0, password1) -> do
if password0 == password1
then
-- do your thing
else
-- serve the form again and perhaps set message telling that
-- passwords don't match?
【问题讨论】: