Skip to content

Commit 5b46cd4

Browse files
authored
Prepare 0.1.0.0 release (#46)
1 parent 8dc86be commit 5b46cd4

File tree

4 files changed

+25
-15
lines changed

4 files changed

+25
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
`validation-selective` uses [PVP Versioning][1].
44
The changelog is available [on GitHub][2].
55

6-
## Unreleased
6+
## 0.1.0.0 — May 5, 2020
77

88
* [#41](https://github.com/kowainik/relude/issues/41):
99
Support GHC-8.10.1.
10-
(by [@chshersh](https://github.com/chshersh))
1110
* [#24](https://github.com/kowainik/relude/issues/24):
1211
Add `validationAll`, `when*` and `maybe*` combinators into
1312
`Validation.Combinators`.
14-
(by [@vrom911](https://github.com/vrom911))
1513

1614
## 0.0.0.0
1715

src/Validation.hs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ validatePassword password =
271271
validateShortPassword password *> validatePasswordDigit password
272272
:}
273273
274+
274275
Let's see how it works:
275276
276277
>>> validatePassword "abcd"
@@ -280,6 +281,17 @@ Failure (ShortPassword :| [])
280281
>>> validatePassword "abcd12345"
281282
Success "abcd12345"
282283
284+
The @validation@ library provides several convenient combinators, so
285+
you can write the password check in a shorter way:
286+
287+
@
288+
validatePassword :: 'String' -> 'Validation' ('NonEmpty' FormValidationError) Password
289+
validatePassword = 'fmap' Password . 'validateAll'
290+
[ (\`'failureIf'\` ShortPassword) . (< 8) . 'length'
291+
, (\`'failureUnless'\` NoDigitPassword) . 'any' isDigit
292+
]
293+
@
294+
283295
After we've implemented validations for all fields, we can compose
284296
them together to produce validation for the whole @User@. As before,
285297
we are going to use the 'Applicative' instance:
@@ -1129,7 +1141,7 @@ failure e = Failure (e :| [])
11291141
{-# INLINE failure #-}
11301142

11311143
{- | Returns a 'Failure' in case of the given predicate is 'True'.
1132-
Returns @'Success' '()'@ otherwise.
1144+
Returns @'Success' ()@ otherwise.
11331145
11341146
>>> let shouldFail = (==) "I am a failure"
11351147
>>> failureIf (shouldFail "I am a failure") "I told you so"
@@ -1144,7 +1156,7 @@ failureIf p e
11441156
{-# INLINE failureIf #-}
11451157

11461158
{- | Returns a 'Failure' unless the given predicate is 'True'.
1147-
Returns @'Success' '()'@ in case of the predicate is satisfied.
1159+
Returns @'Success' ()@ in case of the predicate is satisfied.
11481160
11491161
Similar to 'failureIf' with the reversed predicate.
11501162

src/Validation/Combinators.hs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@ start element when all checks are successful.
3939
A basic example of usage could look like this:
4040
4141
@
42-
> let validatePassword = validateAll
42+
> __let__ validatePassword = 'validateAll'
4343
[ validateEmptyPassword
4444
, validateShortPassword
4545
]
4646
47-
> validateAll "VeryStrongPassword"
48-
Success "VeryStrongPassword"
47+
> 'validateAll' \"VeryStrongPassword\"
48+
'Success' \"VeryStrongPassword\"
4949
50-
> validateAll ""
51-
Failure (EmptyPassword :| [ShortPassword])
50+
> 'validateAll' ""
51+
'Failure' (EmptyPassword :| [ShortPassword])
5252
@
5353
-}
5454
validateAll
@@ -77,7 +77,7 @@ whenFailure a (Success _) _ = pure a
7777

7878
{- | Applies given action to the 'Validation' content if it is 'Failure'.
7979
80-
Similar to 'whenFailure' but the default value is '()'.
80+
Similar to 'whenFailure' but the default value is @()@.
8181
8282
>>> whenFailure_ (Success 42) putStrLn
8383
>>> whenFailure_ (Failure "foo") putStrLn
@@ -104,7 +104,7 @@ whenFailureM x mv f = mv >>= \v -> whenFailure x v f
104104

105105
{- | Monadic version of 'whenFailure_'.
106106
Applies monadic action to the given 'Validation' in case of 'Failure'.
107-
Similar to 'whenFailureM' but the default is '()'.
107+
Similar to 'whenFailureM' but the default is @()@.
108108
109109
>>> whenFailureM_ (pure $ Success 42) putStrLn
110110
>>> whenFailureM_ (pure $ Failure "foo") putStrLn
@@ -131,7 +131,7 @@ whenSuccess _ (Success a) f = f a
131131

132132
{- | Applies given action to the 'Validation' content if it is 'Success'.
133133
134-
Similar to 'whenSuccess' but the default value is '()'.
134+
Similar to 'whenSuccess' but the default value is @()@.
135135
136136
>>> whenSuccess_ (Failure "foo") print
137137
>>> whenSuccess_ (Success 42) print
@@ -158,7 +158,7 @@ whenSuccessM x mv f = mv >>= \v -> whenSuccess x v f
158158

159159
{- | Monadic version of 'whenSuccess_'.
160160
Applies monadic action to the given 'Validation' in case of 'Success'.
161-
Similar to 'whenSuccessM' but the default is '()'.
161+
Similar to 'whenSuccessM' but the default is @()@.
162162
163163
>>> whenSuccessM_ (pure $ Failure "foo") print
164164
>>> whenSuccessM_ (pure $ Success 42) print

validation-selective.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 2.4
22
name: validation-selective
3-
version: 0.0.0.1
3+
version: 0.1.0.0
44
synopsis: Lighweight pure data validation based on Applicative and Selective functors
55
description:
66
Lighweight pure data validation based on Applicative and Selective

0 commit comments

Comments
 (0)