Skip to content
Snippets Groups Projects
Verified Commit 06b1638d authored by jan.hamal.dvorak's avatar jan.hamal.dvorak
Browse files

Make Form exports more ergonomic

parent ea445ffd
Branches
No related tags found
No related merge requests found
...@@ -31,10 +31,11 @@ module Hikaru.Form ...@@ -31,10 +31,11 @@ module Hikaru.Form
, multiSelectField' , multiSelectField'
, opt , opt
, req , req
, whenChecking
, fieldShouldCheck
, fieldValue
, addNote , addNote
, addAttribute , addAttribute
, fieldCheck
, fieldValue
, hasErrors , hasErrors
) )
where where
...@@ -433,18 +434,12 @@ where ...@@ -433,18 +434,12 @@ where
-- --
req :: (Monad m) => l -> FieldT l a m () req :: (Monad m) => l -> FieldT l a m ()
req label = do req label = do
shouldCheck <- fieldCheck whenChecking do
if shouldCheck
then do
value <- fieldValue value <- fieldValue
case value of case value of
Nothing -> addNote $ NoteError label Nothing -> addNote $ NoteError label
Just _v -> return () Just _v -> return ()
else do
return ()
-- | -- |
-- TODO -- TODO
...@@ -466,8 +461,20 @@ where ...@@ -466,8 +461,20 @@ where
-- | -- |
-- TODO -- TODO
-- --
fieldCheck :: (Monad m) => FieldT l a m Bool whenChecking :: (Monad m) => FieldT l a m b -> FieldT l a m ()
fieldCheck = FieldT (fst <$> ask) whenChecking checkField = do
check <- fieldShouldCheck
if check
then checkField >> return ()
else return ()
-- |
-- TODO
--
fieldShouldCheck :: (Monad m) => FieldT l a m Bool
fieldShouldCheck = FieldT (fst <$> ask)
-- | -- |
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment