Lighweight pure data validation based on Applicative.
Lighweight pure data validation based on Applicative. The library provides the following Either-like data type with suitable instances like Semigroup to accumulate validation errors in the Failure
branch :
data
Validation e a
= Failure e
| Success a
validation-micro
Lightweight pure data validation based on Applicative
.
validation-micro
is built around the following data type:
data Validation e a
= Failure e
| Success a
This data type is similar to Either
but allows accumulating all errors instead of short-circuiting on the first one.
Comparison with other packages
validation-micro
is not the only package that provides the Validation
data type. Here are some differences and commonalities to other validation packages:
- Lightweight.
validation-micro
depends only onbase
anddeepseq
, which make it fast to build. So adding validation capabilities to your library or application doesn't contribute much to your dependency footprint. - Future-proof. Both
base
anddeepseq
are GHC boot packages, which means thatvalidation-micro
can be imported as long as GHC can run. - No Selective instance. This means you cannot choose which validation to use based on the value. On the other hand, we don't need to depend on
selective
which is a somewhat experimental package. - No Monad instance - but there is a
bindValidation
utility function which behaves like(>>=)
.
Copyright
Copyright: (c) 2014 Chris Allen, Edward Kmett (c) 2018-2023 Kowainik (c) 2023 Marco Zocca License: BSD3 Maintainer: [email protected].