Skip to content

owainlewis/validated

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Validated

A custom type for data validation

import Data.Validated

>> validateN :: Int -> Validated [String] Int
>> validateN n = if n > 10 then Valid n else Invalid [show n ++ " is not greater than 10"]

-- Accumulating failures

>> foldl1 (<>) $ filter isValid $ map validateN [1..20]

Invalid ["1 is not greater than 10","2 is not greater than 10","3 is not greater than 10","4 is not greater than 10","5 is not greater than 10","6 is not greater than 10","7 is not greater than 10","8 is not greater than 10","9 is not greater than 10","10 is not greater than 10"]

About

A data type for simple validation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published