9

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")})
amsayk
  • 91
  • 3

1 Answers1

9

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
  • 1,894
  • 14
  • 27
  • 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 Oct 02 '10 at 09:42
  • I did try (against scala 2.8 and hibernate validator), and it doesn't work. Did you try? – Vasil Remeniuk Oct 02 '10 at 12:23
  • Your code gives "error: org.hibernate.validator.constraints.ScriptAssert does not have a constructor: new ScriptAssert(script = "...", lang = "javascript")))" – Vasil Remeniuk Oct 02 '10 at 12:46
  • 1
    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 Oct 02 '10 at 16:36