refactor(forms): form validation minor refactor
This commit is contained in:
parent
42c3987ee9
commit
b75aed5dda
@ -344,9 +344,9 @@ validateExam = do
|
||||
guardValidation MsgExamClosedMustBeAfterEnd . fromMaybe True $ (>=) <$> efClosed <*> efEnd
|
||||
|
||||
forM_ efOccurrences $ \ExamOccurrenceForm{..} -> do
|
||||
guardValidation (MsgExamOccurrenceEndMustBeAfterStart eofName) $ NTop eofEnd >= NTop (Just eofStart)
|
||||
guardValidation (MsgExamOccurrenceEndMustBeAfterStart eofName) $ NTop eofEnd >= NTop (Just eofStart)
|
||||
guardValidation (MsgExamOccurrenceStartMustBeAfterExamStart eofName) $ NTop (Just eofStart) >= NTop efStart
|
||||
warnValidation (MsgExamOccurrenceEndMustBeBeforeExamEnd eofName) $ NTop eofEnd <= NTop efEnd
|
||||
warn_Validation (MsgExamOccurrenceEndMustBeBeforeExamEnd eofName) $ NTop eofEnd <= NTop efEnd
|
||||
|
||||
forM_ [ (a, b) | a <- Set.toAscList efOccurrences, b <- Set.toAscList efOccurrences, b > a ] $ \(a, b) -> do
|
||||
eofRange' <- formatTimeRange SelFormatDateTime (eofStart a) (eofEnd a)
|
||||
|
||||
@ -944,14 +944,15 @@ guardValidationM :: ( MonadHandler m
|
||||
=> msg -> m Bool -> FormValidator r m ()
|
||||
guardValidationM = (. lift) . (=<<) . guardValidation
|
||||
|
||||
|
||||
warnValidation :: ( MonadHandler m
|
||||
-- | like `guardValidation`, but issues a warning instead
|
||||
warn_Validation :: ( MonadHandler m
|
||||
, RenderMessage (HandlerSite m) msg
|
||||
)
|
||||
=> msg -- ^ Message describing violation
|
||||
-> Bool -- ^ @False@ iff constraint is violated
|
||||
-> FormValidator r m ()
|
||||
warnValidation msg isValid = unless isValid $ addMessageI Warning msg
|
||||
warn_Validation msg isValid = unless isValid $ addMessageI Warning msg
|
||||
|
||||
|
||||
-----------------------
|
||||
-- Form Manipulation --
|
||||
|
||||
Loading…
Reference in New Issue
Block a user