frame-0.1: A simple web framework.

Frame.Validation

Contents

Description

Functions for validation of fields

Synopsis

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

notEmptySource

Arguments

:: WrapperType

The wrapped value to check

-> Maybe String

Nothing if it's not empty, otherwise an error message

Cannot be empty

shorterThanSource

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

greaterThanSource

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

withinBoundsSource

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