{-# 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
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Data Validation inspired by JSR305
License
leptonyu/menshen
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Data Validation inspired by JSR305
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published