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.7 && <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
Category Web
Home page https://github.com/leptonyu/menshen#readme
Uploaded by leptonyu at Mon Apr 1 08:54:53 UTC 2019
Distributions LTSHaskell:0.0.3, NixOS:0.0.3, Stackage:0.0.3
Downloads 412 total (50 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

Maintainer's Corner

For package maintainers and hackage trustees


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