Safe Haskell | Safe |
---|---|
Language | Haskell98 |
This module contains two classes. FormInput
is a class which is parameterized over the input
type used to represent form data in different web frameworks. There should be one instance for each framework, such as Happstack, Snap, WAI, etc.
The FormError
class is used to map error messages into an application specific error type.
Synopsis
- data CommonFormError input
- = InputMissing FormId
- | NoStringFound input
- | NoFileFound input
- | MultiFilesFound input
- | MultiStringsFound input
- | MissingDefaultValue
- commonFormErrorStr :: (input -> String) -> CommonFormError input -> String
- commonFormErrorText :: (input -> Text) -> CommonFormError input -> Text
- class FormError input err where
- commonFormError :: CommonFormError input -> err
- class FormInput input where
- type FileType input
- getInputString :: FormError input err => input -> Either err String
- getInputStrings :: input -> [String]
- getInputText :: FormError input err => input -> Either err Text
- getInputTexts :: input -> [Text]
- getInputFile :: FormError input err => input -> Either err (FileType input)
Documentation
data CommonFormError input Source #
an error type used to represent errors that are common to all backends
These errors should only occur if there is a bug in the ditto-*
packages. Perhaps we should make them an Exception
so that we can
get rid of the FormError
class.
InputMissing FormId | |
NoStringFound input | |
NoFileFound input | |
MultiFilesFound input | |
MultiStringsFound input | |
MissingDefaultValue |
Instances
Eq input => Eq (CommonFormError input) Source # | |
Defined in Ditto.Backend (==) :: CommonFormError input -> CommonFormError input -> Bool # (/=) :: CommonFormError input -> CommonFormError input -> Bool # | |
Ord input => Ord (CommonFormError input) Source # | |
Defined in Ditto.Backend compare :: CommonFormError input -> CommonFormError input -> Ordering # (<) :: CommonFormError input -> CommonFormError input -> Bool # (<=) :: CommonFormError input -> CommonFormError input -> Bool # (>) :: CommonFormError input -> CommonFormError input -> Bool # (>=) :: CommonFormError input -> CommonFormError input -> Bool # max :: CommonFormError input -> CommonFormError input -> CommonFormError input # min :: CommonFormError input -> CommonFormError input -> CommonFormError input # | |
Show input => Show (CommonFormError input) Source # | |
Defined in Ditto.Backend showsPrec :: Int -> CommonFormError input -> ShowS # show :: CommonFormError input -> String # showList :: [CommonFormError input] -> ShowS # |
:: (input -> String) | show |
-> CommonFormError input | |
-> String |
some default error messages for CommonFormError
:: (input -> Text) | show |
-> CommonFormError input | |
-> Text |
some default error messages for CommonFormError
class FormError input err where Source #
A Class to lift a CommonFormError
into an application-specific error type
commonFormError :: CommonFormError input -> err Source #
class FormInput input where Source #
Class which all backends should implement.
input
is here the type that is used to represent a value
uploaded by the client in the request.
getInputString :: FormError input err => input -> Either err String Source #
Parse the input into a string. This is used for simple text fields among other things
getInputStrings :: input -> [String] Source #
Should be implemented
getInputText :: FormError input err => input -> Either err Text Source #
Parse the input value into Text
getInputTexts :: input -> [Text] Source #
Can be overriden for efficiency concerns
getInputFile :: FormError input err => input -> Either err (FileType input) Source #
Get a file descriptor for an uploaded file