Want more features on Pastebin? Sign Up, it's FREE!
Guest

Grails Shared validators

By: amitjain1982 on Jan 20th, 2012  |  syntax: Groovy  |  size: 0.47 KB  |  views: 1,276  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }
clone this paste RAW Paste Data