menshen: Data Validation

[ bsd3, library, web ] [ Propose Tags ]

Data Validation inspired by JSR305


[Skip to Readme]
Versions [faq] 0.0.0, 0.0.1 (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 Thu Jan 17 07:16:26 UTC 2019
Distributions LTSHaskell:0.0.1, NixOS:0.0.1, Stackage:0.0.1
Downloads 120 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.1

[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

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

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

main = do
  print $ makeBody "daniel" 15