Validate values, such as common user inputs; emails, age, address, credit card, web address, etc.
- module Data.GenericString
- type Test e a b = Maybe a -> Input e (Maybe b)
- validate :: Str e => Test e a b -> a -> Maybe [e]
- test :: Str e => e -> (a -> Bool) -> Test e a a
- label :: Str e => e -> Test e a b -> Test e a b
- equal :: (Show a, Eq a, Str e) => a -> Test e a a
- isInt :: Str e => Test e e e
- less :: (Str e, Ord a, Show a) => a -> Test e a a
- more :: (Str e, Ord a, Show a) => a -> Test e a a
- age :: (Str e, Str s) => Test e s Int
- pattern :: (Str e, Str s) => e -> s -> Test e s s
- int :: (Str e, Str s) => Test e s Int
- float :: (Str e, Str s) => Test e s Float
Documentation
module Data.GenericString
Validation
:: Str e | |
=> Test e a b | Test to perform. |
-> a | Value on which to perform the test. |
-> Maybe [e] | Maybe a list of errors, or Nothing, meaning success. |
Validate some input with testing function.
Testing utilities
:: Str e | |
=> e | Error if predicate fails. |
-> (a -> Bool) | Predicate to test the value with. |
-> Test e a a | A test from a to a. |
A generic testing function with a predicate, with type preservation.
:: Str e | |
=> e | Error message to attach if test fails. |
-> Test e a b | Test whose result is checked for failure. |
-> Test e a b | A new test from a to b which shows the label as an error on failure. |
Attach a "label" around a testing function which errors. This might be useless.
Testing functions
:: (Str e, Ord a, Show a) | |
=> a | Something which the value being test must be less than. |
-> Test e a a | A test from a to a which tests this property. |
Check that a a value is less than a specified value.
more :: (Str e, Ord a, Show a) => a -> Test e a aSource
Like less but the value must be more than the specified value.
age :: (Str e, Str s) => Test e s IntSource
Test that a given age is correct (130 years of age max.). http:www.seniorjournal.comNEWSSeniorStats/5-12-03-NoOne123.htm
:: (Str e, Str s) | |
=> e | An error message if the match fails. |
-> s | The regular expression |
-> Test e s s | The produced testing function. |
Make a test which tests a string according to a regular expression pattern.