Advertisement
amitjain1982

Grails Shared validators

Jan 20th, 2012
3,080
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 0.47 KB | None | 0 0
  1. class Validators {
  2.    
  3.     static final confirmPasswordValidator = { value, command ->
  4.         if (command.password != command.confirmPassword) {
  5.             return 'command.confirmPassword.error.mismatch'
  6.         }
  7.     }
  8.  
  9.     static def requiresAtleastOne =  {val, obj->
  10.         if(!val?.size()){
  11.             return "default.requires.atleast.one"
  12.         }
  13.     }
  14. }
  15.  
  16.  
  17. class MyDomain {
  18.     ...
  19.     static constraints = {
  20.           items(validator: requiresAtleastOne)
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement