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-microdepends only onbaseanddeepseq, 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
baseanddeepseqare GHC boot packages, which means thatvalidation-microcan 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
selectivewhich is a somewhat experimental package. - No Monad instance - but there is a
bindValidationutility 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].