Frame.Validation
Contents
Description
Functions for validation of fields
- type Validators = Map FieldName [WrapperType -> Maybe String]
- validate :: Validators -> Fields -> Map FieldName [Maybe String]
- validateField :: [WrapperType -> Maybe String] -> WrapperType -> [Maybe String]
- allValidated :: Validators -> Fields -> Bool
- notEmpty :: WrapperType -> Maybe String
- shorterThan :: Int -> WrapperType -> Maybe String
- greaterThan :: Int -> WrapperType -> Maybe String
- withinBounds :: WrapperType -> Maybe String
Documentation
type Validators = Map FieldName [WrapperType -> Maybe String]Source
A validator is a map associating field names to a list of functions taking a wrapped type to a potential (error) string
Helper methods
validate :: Validators -> Fields -> Map FieldName [Maybe String]Source
Validate a whole set of fields against a set of validators
validateField :: [WrapperType -> Maybe String] -> WrapperType -> [Maybe String]Source
Validate a particular field against a list of validators
allValidated :: Validators -> Fields -> BoolSource
True if all fields validate against a set of validators
Validation functions
Arguments
:: WrapperType | The wrapped value to check |
-> Maybe String | Nothing if it's not empty, otherwise an error message |
Cannot be empty
Arguments
:: Int | Length to be shorter than |
-> WrapperType | The wrapped value to check |
-> Maybe String | Nothing if it's shorter, otherwise an error message |
Must be shorter than a given length
Arguments
:: Int | Number to be greater than |
-> WrapperType | The wrapped value to check |
-> Maybe String | Nothing if it's greater, otherwise an error |
Must be greater than a given number
Arguments
:: WrapperType | The wrapped type to check |
-> Maybe String | Nothing if it's within bounds, otherwise an error |
A type level check to make sure a string is within the bounds defined