Open
Description
It would be really useful if the validate
and ensure
used (a -> Maybe b)
instead of (a -> Bool)
. This would allow the user to output an updated, validated value as a result.
For example, my current use case is that I'm validating an Integer
to a Natural
, ensuring that the Integer
is (n >= 0)
.
So I could do:
positive :: Integer -> Validation Errors Natural
positive n =
validate (pure $ NegativeVal n) (if n <= then Just $ fromInteger n else Nothing) n
What do you think? :)
Metadata
Metadata
Assignees
Labels
No labels