Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a validate combinator to DecodeResult #135

Open
chrislewis opened this issue Aug 24, 2014 · 0 comments
Open

Add a validate combinator to DecodeResult #135

chrislewis opened this issue Aug 24, 2014 · 0 comments

Comments

@chrislewis
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants