-
Notifications
You must be signed in to change notification settings - Fork 55
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
Getting indexed description when composing validators #86
Comments
FYI we are using Scala 2.11.8. |
Managed to reproduce the problem, I'll follow up when I have something useful to say... |
Current status: Problem reproduced successfully and is well-understood. The bad news: The description model is fundamentally limited, and I can't believe I hadn't thought of - or run into - this before; it basically cannot represent interleaved indexed- and named-access. To clarify, the example above logically fails to validate I'll try to code up a proper representation in the next day or two; unfortunately this will be a breaking API change, and I'm still wondering if this necessitates a (depressingly thin) |
TL;DR there's a workaround, see below. I've managed to whittle this down to the following reproduction case: case class TestElement( property: String )
case class CollectionOfIndirections( field: Seq[ TestElement ] )
val elementValidator = validator[ TestElement ] { c => c.property is notEmpty }
val collectionOfIndirectionsValidator =
// Designed to produce descriptions such as coi.coll[0].property
validator[ CollectionOfIndirections ] { coi => coi.field.each is elementValidator }
val sample = CollectionOfIndirections( Seq( TestElement( "" ) ) )
val result = validate( sample )( collectionOfIndirectionsValidator ) // <-- Exception here The reason this has never come up is that Accord espouses using So:
|
@zbeckman Does this workaround solve your immediate problem? |
Well... Yes. But... ;-) The workaround works, but it's bulky. So I'm torn between doing it "right" and just doing something much simpler:
meh... But yes, it does work, and I'll probably go with the "right" way if nothing else then I'll have a documented instance of how to do it. ;-) |
@zbeckman Fixed! You should be able to verify with 0.7-SNAPSHOT. I'll wait on your feedback and then release 0.6.1. |
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:
The above code generates the following error during runtime:
I 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):This is posing a nasty little problem for me in our current project – it would be great if a solution can be developed... Thanks!
The text was updated successfully, but these errors were encountered: