views:

99

answers:

1

Help,

how do i do stuff like the following in Scala?

import org.hibernate.validator.constraints.ScriptAssert

@ScriptAssert.List({
    @ScriptAssert(script = "...", lang = "javascript"),
    @ScriptAssert(script = "...", lang = "javascript")})
+1  A: 

The correct syntax is as follows (Array(...) for arrays, new Nested(..) for nested annotations):

import org.hibernate.validator.constraints.ScriptAssert

@ScriptAssert.List(Array(
  new ScriptAssert(script = "...", lang = "javascript"),
  new ScriptAssert(script = "...", lang = "javascript")))
class Test
Lukas Rytz
It won't work due to a known bug.
Vasil Remeniuk
Did you try it? Using Scala 2.8, this works for me. I just got the syntax wrong in my initial answer, but now it's corrected.
Lukas Rytz
I did try (against scala 2.8 and hibernate validator), and it doesn't work. Did you try?
Vasil Remeniuk
Your code gives "error: org.hibernate.validator.constraints.ScriptAssert does not have a constructor: new ScriptAssert(script = "...", lang = "javascript")))"
Vasil Remeniuk
You need to put validation-api into the classpath. Here's the command I used for compiling the thing: `~/scala/dist/bin/scalac -cp /Users/luc/Downloads/hib/hibernate-validator-4.1.0.Final.jar:/Users/luc/Downloads/hib/validation-api-1.0.CR5.jar test.scala`
Lukas Rytz