keuringsdienst 0.1.0.5 → 0.1.1.0
raw patch · 5 files changed
+13/−124 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.org +8/−0
- ChangeLog.md +0/−22
- ChangeLog.org +0/−8
- README.md +0/−87
- keuringsdienst.cabal +5/−7
+ CHANGELOG.org view
@@ -0,0 +1,8 @@+* Changelog for `keuringsdienst`++All notable changes to this project will be documented in this file.++The format is based on Keep a Changelog - https://keepachangelog.com/en/1.0.0/, and this project adheres to the Haskell Package Versioning Policy - https://pvp.haskell.org/.++** v0.1.0.2+- First stable API release
− ChangeLog.md
@@ -1,22 +0,0 @@--# Table of Contents--1. [Changelog for \`keuringsdienst\`](#org1c49459)- 1. [v0.1.0.2](#org8ac1b09)---<a id="org1c49459"></a>--# Changelog for \`keuringsdienst\`--All notable changes to this project will be documented in this file.--The format is based on Keep a Changelog - <https://keepachangelog.com/en/1.0.0/>, and this project adheres to the Haskell Package Versioning Policy - <https://pvp.haskell.org/>.---<a id="org8ac1b09"></a>--## v0.1.0.2--- First stable API release-
− ChangeLog.org
@@ -1,8 +0,0 @@-* Changelog for `keuringsdienst`--All notable changes to this project will be documented in this file.--The format is based on Keep a Changelog - https://keepachangelog.com/en/1.0.0/, and this project adheres to the Haskell Package Versioning Policy - https://pvp.haskell.org/.--** v0.1.0.2-- First stable API release
− README.md
@@ -1,87 +0,0 @@---# Keuringsdienst (van Waarde)-- --If you know, you know. Data validation in Haskell that is composable, made easy and clean.--Licensed under the GNU General Public License v3 or later.--Data validation rules that are easy to write and serve as documentation of your data as well. Therefore, data validations **SHOULD** live next to your data models.---## Context and motivation--There exist many data validation packages, in Haskell and other languages, but so far I have never found something that was flexible but powerful enough for my needs.--I based myself on `Semigroup` and `Monoid` operations, and attempted to make validation rules that are easy to write, read, compose and maintain.--See an example, from my music website WikiMusic.-- validateEntity x =- (identifier x) |?| isTextOfLength 36- <> (displayName x) |?| (isNonEmptyText <> isTextSmallerThanOrEqual 120)--Imagine a simple data model (record) for a music artist:-- data Artist = Artist- { identifier :: Text,- displayName :: Text,- createdBy :: Text,- visibilityStatus :: Int,- approvedBy :: Maybe Text,- createdAt :: UTCTime,- lastEditedAt :: Maybe UTCTime,- artworks :: Map Text ArtistArtwork,- comments :: Map Text ArtistComment,- opinions :: Map Text ArtistOpinion,- spotifyUrl :: Maybe Text- }- deriving (Eq, Show, Generic)---## Defining validations--Of course for all this to work, you need some imports:-- import Keuringsdienst- import Keuringsdienst.Helpers--You can define a validation function for `Artist` by composing validation results and rules. Validation results are the result of applying rules to certain data and can be composed with `<>` since they are `Monoid`. Rules can also be composed (`AND`) with `<>` since they are also `Monoid` and can be `OR`'ed with the `*||*` operator, a.k.a `ofDitOfDat`.-- validateArtist :: Artist -> ValidationResult- validateArtist x =- (identifier x) |?| isTextOfLength 36- <> (displayName x) |?| (isNonEmptyText <> isTextSmallerThanOrEqual 120)- <> (createdBy x) |?| isTextOfLength 36- <> (visibilityStatus x) |?| isPositiveOrZero- <> (approvedBy x) |??| isTextOfLength 36- <> (spotifyUrl x) |??| isNonEmptyText---## What is a ValidationResult-- type ErrMsg = Text- - data Validation err- = Success- | Failure err- deriving (Eq, Show, Generic, FromJSON, ToJSON)- - type ValidationResult = Validation [ErrMsg]---## Optics / Lenses--If you like `Optics` and lenses as I do, you are fully free to use it:-- validateArtist :: Artist -> ValidationResult- validateArtist x =- (x ^. #identifier) |?| isTextOfLength 36- <> (x ^. #displayName) |?| (isNonEmptyText <> isTextSmallerThanOrEqual 120)- <> (x ^. #createdBy) |?| isTextOfLength 36- <> (x ^. #visibilityStatus) |?| isPositiveOrZero- <> (x ^. #approvedBy) |??| isTextOfLength 36- <> (x ^. #spotifyUrl) |??| isNonEmptyText-
keuringsdienst.cabal view
@@ -5,24 +5,22 @@ -- see: https://github.com/sol/hpack name: keuringsdienst-version: 0.1.0.5+version: 0.1.1.0 synopsis: Data validation in Haskell made easy. description: Data validation in Haskell made easy and clean, with user rules that can be combined. category: Validation, Data-author: Josep Bigorra-maintainer: Josep Bigorra+author: Josep Jesus Bigorra Algaba+maintainer: Josep Jesus Bigorra Algaba license: GPL-3 license-file: COPYING build-type: Simple extra-source-files:- README.md README.org- ChangeLog.md- ChangeLog.org+ CHANGELOG.org source-repository head type: git- location: https://git.sr.ht/~teutonicjoe/keuringsdienst+ location: https://gitlab.com/jjba-projects/keuringsdienst library exposed-modules: