Using Groovy Validators in the Groovy Shell

I used the Groovy shell to test my Groovy validators. I learned a little bit more about the Groovy shell in the process.

When you declare a class in the shell, you cannot include a package.

Also, when you use the annotations on fields, you have to put the annotations on the same line as the fields. Class annotations can still be on separate line as the class declaration.

So instead of this:

you would have to do this:

Note that @ToString does not need to be on the same line as “class Person”. Aside from that, it is no different than using the annotations in code or the console.

You’re welcome.

Image from “Sacramentaire ou Missel de Worms. — Neumes”, a 10th century manuscript housed at the Bibliothèque nationale de France. Source gallica.bnf.fr / BnF; image assumed allowed under Fair Use.