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

JSON Reads max and min combinators should work on any Numeric #1363

Merged
merged 2 commits into from
Jul 26, 2013

Conversation

mariussoutier
Copy link
Contributor

The Reads.min and Reads.max combinators in play-json currently only work on Int, but there's no reason it shouldn't work any any Numeric.

@cloudbees-pull-request-builder

play2-master-PRs #392 SUCCESS
This pull request looks good

def min(m: Int)(implicit reads: Reads[Int]) =
filterNot[Int](ValidationError("error.min", m))(_ < m)(reads)
/**
* Defines a minimum size for a numeric Reads. Combine with `max` using `or`, e.g.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not using the word "size", it's more about the value, isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you're right, fixed it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no you can commit on your branch and the PR is updated!

On Fri, Jul 19, 2013 at 3:10 PM, Marius Soutier notifications@github.comwrote:

In
framework/src/play-json/src/main/scala/play/api/libs/json/JsConstraints.scala:

@@ -112,11 +112,19 @@ trait ConstraintReads {
def seq[A](implicit reads: Reads[A]): Reads[Seq[A]] = Reads.traversableReads[Seq, A]
def map[A](implicit reads: Reads[A]): Reads[collection.immutable.Map[String, A]] = Reads.mapReads[A]

  • def min(m: Int)(implicit reads: Reads[Int]) =
  • filterNot[Int](ValidationError%28"error.min", m%29)(_ < m)(reads)
  • /**
  • * Defines a minimum size for a numeric Reads. Combine with max using or, e.g.

Yes you're right... I guess I have to close this PR and submit a new one?


Reply to this email directly or view it on GitHubhttps://github.com//pull/1363/files#r5291461
.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, see below. value was just the word I was looking for but then I resorted to size.

@mandubian
Copy link
Contributor

Seems OK ;)

@cloudbees-pull-request-builder

play2-master-PRs #393 SUCCESS
This pull request looks good

jroper added a commit that referenced this pull request Jul 26, 2013
JSON Reads max and min combinators should work on any Numeric
@jroper jroper merged commit a7d8fed into playframework:master Jul 26, 2013
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

Successfully merging this pull request may close these issues.

4 participants