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

formatInline does not catch IllegalArgumentExceptions #48

Open
dhoepelman opened this issue Mar 14, 2018 · 0 comments
Open

formatInline does not catch IllegalArgumentExceptions #48

dhoepelman opened this issue Mar 14, 2018 · 0 comments

Comments

@dhoepelman
Copy link
Contributor

dhoepelman commented Mar 14, 2018

We've been using this library in combination with require to constrain our domain objects, but still get nice JsErrors back.

Unfortunately this does not work with Jsonx.formatInline

case class PositiveInteger(i: Int) {
   require(i >= 1, "Number must be a positive integer")
}

import play.api.libs.json.Json
// JsError(ValidationError("Number must be a positive integer"))
Jsonx.formatCaseClass[PositiveInteger].reads(Json.parse("""{ "i": -1 }""")))

// IllegalArgumentException("Number must be a positive integer") gets thrown
Jsonx.formatInline[PositiveInteger].reads(Json.parse("-1")))

I might be able to create a PR for this friday if this is wanted

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

No branches or pull requests

1 participant