argonaut
argonaut copied to clipboard
Add a validate combinator to DecodeResult
A validate
combinator on DecodeResult
would make it easier to apply logic to json structures that parsed correctly but require further validation. For example, with this feature we might parse a Latitude
instance and constrain its value like so:
DecodeJson(c => for {
lat <- (c --\ "lat").as[Double].validate(_.abs <= 90d, "Latitude must be within (+/-)90")
} yield Latitude(lat))
In order to preserve the cursor history without adding an addition argument to validate
, this issue depends on #134.