in the Form: ... (hamletHtmlResult, hamletHtmlView) <- mreq validatedHamletTextareaField ... the field: validatedHamletTextareaField :: Field (HandlerFor App) Textarea validatedHamletTextareaField = checkM isValidHamlet textareaField where isValidHamlet :: Textarea -> Handler (Either AppMessage Textarea) isValidHamlet textarea@(Textarea text) = do eitherParsedTemplate <- tryParse text return $ case eitherParsedTemplate of Left _ -> Left MsgGlobalInvalidHamlet Right _ -> Right $ Textarea text where tryParse :: Text -> Handler (Either SomeException HamletTemplate) tryParse text = try $ parseHamletTemplate defaultHamletSettings $ unpack text
Tuesday, December 31, 2019
Validated Hamlet Textarea Form Field
Here is my custom textarea field that validates correct hamlet content
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment