2
votes

I have this auto generated lines of codes:

EPRole validator: { EPRole r, EPUserEPRole ur ->
            if (ur.EPUser == null) return
            boolean existing = false
            EPUserEPRole.withNewSession {
                existing = EPUserEPRole.exists(ur.EPUser.id, r.id)
            }
            if (existing) {
                return 'userRole.exists'
            }
        }

When I try to compile the code I get 82: unexpected token: validator @ line 82, column 10.

I am new in groovy so any help is appreciated.

1
should be epRole? EPRole would be the classcfrick
Ah, now I get it. The whole class is auto generated and you are right that the error depend on capital and lower cases. How can I accept your answer as correct?bel

1 Answers

2
votes

You should add your properties with the proper type and name to the class. First letter uppercase is for classes (or types in general). So there should be in your EPUserEPRole a property like this:

EPRole epRole

Then add the validator for epRole. Pay attention to the case.

Above code would confuse the groovy parser into defining a property validator of type EPRole followed by a :, hence the error (or else it would try to call the method EPRole with the map, depending on context).