I have a special validator, for example -
validator: { userEmail, userAccount ->
if (userAccount.authenticationChannel == "ABC") {
boolean valid = true;
UserAccount.withNewSession {
if (UserAccount.findByEmail(userEmail)){
valid = false;
}
else if (UserAccount.findByName(userEmail)) {
valid = false;
}
...
So basically, I need a check based on some particular state, and in my check I need to execute a query.
But now, if I do -
def admin = new UserAccount(firstname:'Admin',email:'admin@example.com')
admin.save(flush:true)
admin.addToAuthorities("ADMIN").save(flush:true)
Fails.
Grails starts validation, even when upgrading, and since email authentication fails. How is this different if I do
email {unique:true}
Does Grails say that I cannot write a special validator that checks for uniqueness.
source
share