menshen: Data Validation

[ bsd3, library, web ] [ Propose Tags ]

Data Validation inspired by JSR305


[Skip to Readme]
Versions [faq] 0.0.0, 0.0.1, 0.0.2, 0.0.3 (info)
Dependencies base (>=4.8 && <5), regex-tdfa (>=1.2.3.1 && <1.3), scientific (>=0.3.6.2 && <0.4), text (>=1.2.3.1 && <1.3) [details]
License BSD-3-Clause
Copyright (c) Daniel YU
Author Daniel YU
Maintainer leptonyu@gmail.com
Revised Revision 1 made by HerbertValerioRiedel at Thu Sep 5 20:15:14 UTC 2019
Category Web
Home page https://github.com/leptonyu/menshen#readme
Uploaded by leptonyu at Tue Mar 19 04:06:29 UTC 2019
Distributions LTSHaskell:0.0.3, NixOS:0.0.3, Stackage:0.0.3
Downloads 652 total (63 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs uploaded by user
Build status unknown [no reports yet]

Modules

[Index] [Quick Jump]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

For package maintainers and hackage trustees


Readme for menshen-0.0.2

[back to package description]

menshen

Hackage Build Status


{-# LANGUAGE RecordWildCards #-}
module Main where
import Data.Menshen
data Body = Body
  { name :: String
  , age  :: Int
  } deriving Show

verifyBody :: Validator Body
verifyBody = vcvt $ Body{..} -> Body
  <$> name ?: mark "name" . pattern "^[a-z]{3,6}$"
  <*> age  ?: mark "age"  . minInt 1 . maxInt 150

makeBody :: String -> Int -> Either String Body
makeBody name age = Body{..} ?: verifyBody

main = do
  print $ makeBody "daniel" 15