menshen: Data Validation

[ bsd3, deprecated, library, web ] [ Propose Tags ] [ Report a vulnerability ]
Deprecated

Data Validation inspired by JSR305


[Skip to Readme]

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

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 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 2019-09-05T20:15:15Z
Category Web
Home page https://github.com/leptonyu/menshen#readme
Uploaded by leptonyu at 2019-04-01T08:54:53Z
Distributions
Reverse Dependencies 4 direct, 7 indirect [details]
Downloads 1894 total (3 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for menshen-0.0.3

[back to package description]

menshen

Hackage stackage LTS package stackage Nightly package 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