argonaut icon indicating copy to clipboard operation
argonaut copied to clipboard

Add a validate combinator to DecodeResult

Open chrislewis opened this issue 10 years ago • 0 comments

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.

chrislewis avatar Aug 24 '14 21:08 chrislewis