{"action":"created","issue":{"url":"https://api.github.com/repos/wix/accord/issues/86","repository_url":"https://api.github.com/repos/wix/accord","labels_url":"https://api.github.com/repos/wix/accord/issues/86/labels{/name}","comments_url":"https://api.github.com/repos/wix/accord/issues/86/comments","events_url":"https://api.github.com/repos/wix/accord/issues/86/events","html_url":"https://github.com/wix/accord/issues/86","id":190079827,"number":86,"title":"Getting indexed description when composing validators","user":{"login":"zbeckman","id":5351337,"avatar_url":"https://avatars.githubusercontent.com/u/5351337?v=3","gravatar_id":"","url":"https://api.github.com/users/zbeckman","html_url":"https://github.com/zbeckman","followers_url":"https://api.github.com/users/zbeckman/followers","following_url":"https://api.github.com/users/zbeckman/following{/other_user}","gists_url":"https://api.github.com/users/zbeckman/gists{/gist_id}","starred_url":"https://api.github.com/users/zbeckman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zbeckman/subscriptions","organizations_url":"https://api.github.com/users/zbeckman/orgs","repos_url":"https://api.github.com/users/zbeckman/repos","events_url":"https://api.github.com/users/zbeckman/events{/privacy}","received_events_url":"https://api.github.com/users/zbeckman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-17T15:34:03Z","updated_at":"2016-11-18T13:51:19Z","closed_at":null,"body":"I'm seeing a problem with inappropriately indexed descriptions when I try to compose several different validations. This shows up when I tried to build out the feedback on #82 into real code:\r\n```\r\n  def aValidGuestID: Validator[Int] = between(1, 99)\r\n\r\n  def aValidPaxNumber(bookingNumber: String) = new Validator[String] {\r\n    def apply(pax: String): Result =\r\n      Try(pax.replace(BookingPrefix.concat(bookingNumber), \"\").toInt) match {\r\n        case scala.util.Failure(_) => pax -> \"is not a valid PAX number\"\r\n        case scala.util.Success(id) => aValidGuestID(id)\r\n      }\r\n  }\r\n\r\n  def validForBookingNumber(bookingNumber: String) = validator[GuestDetail] { gd =>\r\n    gd.paxNumber is aValidPaxNumber(bookingNumber)\r\n\r\n    () // Shut up discarded non-Unit value warning\r\n  }\r\n\r\n  implicit val guestBookingValidator = validator[GuestBooking] { (p: GuestBooking) =>\r\n    p.booking is valid\r\n    p.guestDetails is notEmpty\r\n    p.guestDetails.size is between(1, 5)\r\n    p.guestDetails.each is valid\r\n     p.guestDetails.each is validForBookingNumber(p.booking.bookingNumber)\r\n\r\n    () // Shut up discarded non-Unit value warning\r\n  }\r\n```\r\nThe above code generates the following error during runtime:\r\n```\r\njava.lang.IllegalArgumentException: Cannot combine description 'Indexed(0,AccessChain(WrappedArray(paxNumber)))' with 'AccessChain(WrappedArray(guestDetails))'\r\n```\r\nI tried to work around the problem by using `gd.paxNumber as “paxNumber” is aValidPaxNumber(bookingNumber)` but this didn't solve the problem (although it does change the result ever so slightly):\r\n```\r\njava.lang.IllegalArgumentException: Cannot combine description 'Indexed(0,Explicit(paxNumber))' with 'AccessChain(WrappedArray(guestDetails))\r\n```\r\nThis is posing a nasty little problem for me in our current project – it would be great if a solution can be developed... Thanks!"},"comment":{"url":"https://api.github.com/repos/wix/accord/issues/comments/261536044","html_url":"https://github.com/wix/accord/issues/86#issuecomment-261536044","issue_url":"https://api.github.com/repos/wix/accord/issues/86","id":261536044,"user":{"login":"holograph","id":1114848,"avatar_url":"https://avatars.githubusercontent.com/u/1114848?v=3","gravatar_id":"","url":"https://api.github.com/users/holograph","html_url":"https://github.com/holograph","followers_url":"https://api.github.com/users/holograph/followers","following_url":"https://api.github.com/users/holograph/following{/other_user}","gists_url":"https://api.github.com/users/holograph/gists{/gist_id}","starred_url":"https://api.github.com/users/holograph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/holograph/subscriptions","organizations_url":"https://api.github.com/users/holograph/orgs","repos_url":"https://api.github.com/users/holograph/repos","events_url":"https://api.github.com/users/holograph/events{/privacy}","received_events_url":"https://api.github.com/users/holograph/received_events","type":"User","site_admin":false},"created_at":"2016-11-18T13:51:19Z","updated_at":"2016-11-18T13:51:19Z","body":"Managed to reproduce the problem, I'll follow up when I have something useful to say...\r\n"}}
{"actor":{"display_login":"holograph"}}