SHARE
TWEET

Grails Shared validators

amitjain1982 Jan 20th, 2012 1,494 Never
  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. }
RAW Paste Data
Top